ios - Unable to connect code from a third-party library
问题描述
I try to connect this library, but this error falls in the code. I did not find answers in the forums, what am I doing wrong?
https://github.com/miraan/CalendarDateRangePickerViewController
https://yadi.sk/d/Cze6fOwcrV01tA
let dateRangePickerViewController =
CalendarDateRangePickerViewController(collectionViewLayout:
UICollectionViewFlowLayout())
dateRangePickerViewController.delegate = self
let navigationController = UINavigationController(rootViewController:
dateRangePickerViewController)
self.navigationController?.present(navigationController, animated: true,
completion: nil)
解决方案
CalendarDateRangePickerViewController自 2 年以来未更新,因此您需要进行一些更改才能使用该库。
在这里,我使用 Xcode 10.1 实现了它,并按照以下步骤使用它。
首先将 pod 添加到您的 pod 文件中。
pod 'CalendarDateRangePickerViewController'
然后使用pod install
命令。
然后从 Targets 中选择您的 pod。检查下图。
然后第 3 步搜索Swift Language Version
并选择Swift 3
那里。
然后去你想要使用这个库的班级
并添加
import CalendarDateRangePickerViewController
现在您的第三方库已经可以使用了,您可以添加示例代码,如下所示:
import UIKit
import CalendarDateRangePickerViewController
class ViewController: UIViewController, CalendarDateRangePickerViewControllerDelegate {
func didTapCancel() {
}
func didTapDoneWithDateRange(startDate: Date!, endDate: Date!) {
}
override func viewDidLoad() {
super.viewDidLoad()
let dateRangePickerViewController =
CalendarDateRangePickerViewController(collectionViewLayout:
UICollectionViewFlowLayout())
dateRangePickerViewController.delegate = self
let navigationController = UINavigationController(rootViewController:
dateRangePickerViewController)
self.navigationController?.present(navigationController, animated: true,
completion: nil)
}
}
这里是更多信息的示例项目。
编辑:
但是,每当您在终端中点击pod install
或pod update
命令时,您都需要Swift Language Version
再次设置Swift 3
。
推荐阅读
- javascript - 为什么 document.body.style.backgroundImage 名称未显示在警报中?
- javascript - 如何从 ajax 调用中过滤空值或未定义值?
- ios - 滚动时如何使tableView单元格“粘”
- antlr4 - 使用二元运算符解析的不匹配输入
- python - 系统找不到python文件夹
- bash - Sublime 文本环境变量缓存
- django - 我可以在 Django 视图中破坏性地更改我的数据库吗?
- macos - 在 Mac 上安装 PANDAS,大问题
- npm - 如何更新 Npm 包?
- android - 为什么是“Fragment fragment = null”,这个片段定义的含义是什么?