我尝试连接此库,但此错误属于代码。我在论坛上找不到答案,我做错了什么?
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
命令。
然后从目标中选择你的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)
}
}
HERE是更多信息的示例项目。
编辑:
但是每当你在终端击中pod install
或pod update
命令时,你需要再次将Swift Language Version
设置为Swift 3
。