Vuukle 2.0.26

Vuukle 2.0.26

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最近发布2017年5月
SwiftSwift 版本3.0

Vuukle.com维护。



 
依赖项
Alamofire>= 4.3.0
AlamofireImage>= 3.2.0
MBProgressHUD>= 1.0.0
NSDate+TimeAgo>= 1.0.6
 

Vuukle 2.0.26

  • 作者
  • Vuukle.com

'Vuukle' iOS SDK 框架与 Objective-C 和 Swift 3.0(或更高版本)兼容

•Vuukle 主页

安装


[0. 为您的项目创建 Podfile] 如果您已经有了 Podfile,则可以跳过此步骤。

打开终端并将默认目录切换到您的项目目录。

-> Run command 'cd [your project path]' (EXAMPLE: 'cd /Users/fedir/Desktop/ExampleProject')

创建 Podfile。

-> Run command 'pod init' and wait for completion

在 Xcode 中打开 Podfile。

-> Run command 'open -a Xcode podfile'

[1. 将 'Vuukle' 添加到 pods 列表]

如果您刚刚创建了新的 Podfile,请将其中的以下代码行添加到其中(将 'ExampleProject' 替换为您的项目名称)。

platform :ios, '9.0'
 
target '[your project name]' do

  use_frameworks!
  pod 'Vuukle'

end

如果您已经有了 Podfile,只需简单的将 Vuukle 添加到您的 pods 列表中。

pod 'Vuukle'

[!] 对于 OBJECTIVE-C,您应该在 target 结束后定义 Swift 版本。

target '[your project name]' do
   ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|

      config.build_settings['SWIFT_VERSION'] = '3.0'

    end
  end
end

[2. 为项目安装 pods]

关闭您的项目

• EXAMPLE: If you have opened ExampleProject.xcodeproj, close it. After installation of pods you will work with ExampleProject.xcworkspace

(如果在步骤 0 之后关闭了终端。)再次打开终端并将默认目录切换到您的项目目录。

-> Run command 'cd [your project path]' (EXAMPLE: cd /Users/fedir/Desktop/ExampleProject)

为项目安装 pods。

-> Run command 'pod install' and wait for completion

This command will install latest version of pod 'Vuukle' and dependency pods: 

• 'Alamofire'      (version >= 4.3.0)
• 'AlamofireImage' (version >= 3.2.0) 
• 'MBProgressHUD'  (version >= 1.0.0)
• 'NSDate+TimeAgo' (version >= 1.0.6)

[3. 请添加以下参数到 info.plist]

在项目中选择info.plist文件,添加“App Transport Security Settings”,将类型“String”更改为“Dictionary”。然后为“App Transport Security Settings”添加 - Allow Arbitrary Loads,类型为“Boolean”,值为“YES”。 http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http

导入Swift


[4. 将Vuukle添加到嵌入的二进制文件中]

打开安装后生成的.xcworkspace文件。

• EXAMPLE: In project directory open ExampleProject.xcworkspace 

You can also run using terminal:
  -> Run command 'cd [your project path]' (EXAMPLE: cd /Users/fedir/Desktop/ExampleProject)
  -> Run command 'open ExampleProject.xcworkspace'

打开项目设置。

Tap on your project in project navigator (in top left corner)

将Vuukle添加到嵌入的二进制文件中

• Select 'TARGETS' and scroll down to 'Embedded Binaries'
• Tap on '+' button and select 'Add Other...'
• Go to 'Pods -> Vuukle -> Vuukle' and select 'Vuukle.framework' file

[5. 导入Vuukle]

在.swift文件顶部简单添加 'import Vuukle',在其他框架之后使用。

• EXAMPLE: 

import UIKit
import Vuukle

class ExampleViewController: UIViewController {
...

导入Objective-C


[6. 打开工作空间并导入Vuukle]

打开安装后生成的.xcworkspace文件。

EXAMPLE: In project directory open ExampleProject.xcworkspace 

You can also run using terminal:
-> Run command 'cd [your project path]' (EXAMPLE: cd /Users/fedir/Desktop/ExampleProject)
-> Run command 'open ExampleProject.xcworkspace'

打开项目设置。

在项目导航器中点击您自己的项目(左上角)

将Vuukle添加到嵌入的二进制文件中

• 选择'TARGETS'并滚动到' Embedded Binaries' • 点击 '+' 按钮,选择 'Add Other...' • 进入 'Pods -> Vuukle -> Vuukle',选择 'Vuukle.framework' 文件

[7. 导入Vuukle]

在.m文件中的@interface之前简单添加 '#import <Vuukle/Vuukle-Swift.h>'。

• 示例

#import <Vuukle/Vuukle-Swift.h>

@interface ViewController () ... @end

@implementation ViewController ...

Swift使用方式


[8. 将vuukle评论添加到内容视图以展示评论功能]

已在本方法中添加评论 [!] 您已在该UIViewController方法中添加了评论

override func viewWillAppear(_ animated: Bool) { ... }

对于嵌套评论(在Xcode中按住 'Alt' 并点击方法以查看更多详细信息)

VUCommentsBuilder.addVuukleComments(baseVC: [您的视图控制器],baseScrollView: [您的主滚动视图],contentView: [Vuukle的内容视图],contentHeightConstraint: [Vuukle的内容视图高度约束],appName: [应用名称],appID: [应用bundle ID],vuukleApiKey: [Vuukle API密钥],vuukleSecretKey: [Vuukle密钥],vuukleHost: [Vuukle主机],vuukleTimeZone: [您的时区],articleTitle: [文章标题],articleID: [文章ID],articleTag: [文章标签],articleURL: [文章URL])

对于自己的注释滚动(在Xcode中按住'Alt'并单击方法以查看更多详细信息)

VUCommentsBuilder.addVuukleComments(baseVC: [您的视图控制器], contentView: [您的Vuukle内容视图], appName: [应用名称], appID: [应用包标识符], vuukleApiKey: [Vuukle API密钥], vuukleSecretKey: [Vuukle私密密钥], vuukleHost: [Vuukle主机], vuukleTimeZone: [您的时区], articleTitle: [文章标题], articleID: [文章ID], articleTag: [文章标签], articleURL: [文章URL], isScrollEnabled: true, edgeInserts: [评论边缘插入])

【9. 更新所有高度】

【!】您需要在ViewController方法的此位置更新所有高度

override func viewDidAppear(_ animated: Bool) { ... }

要更新高度,请调用方法

VUCommentsBuilder.updateAllHeights()

如果您的应用支持横屏,您必须在旋转后调用此方法。

• 示例

override func didRotate(from fromInterfaceOrientation: UIInterfaceOrientation) { VUCommentsBuilder.updateAllHeights() }

【10. 通过您的应用程序登入】

VUCommentsBuilder.loginUser(name: [您的名称], email: [您的电子邮件])

VUCommentsBuilder.logOut()

【11. 准备就绪,可以运行项目】