我已按照说明在我的应用程序中使用 MBCalendarKit,但它似乎不起作用。我在下面快速发布我的代码。
import UIKit
class ViewController: CKCalendarViewController, CKCalendarViewDelegate , CKCalendarViewDataSource {
var data : NSMutableDictionary
override init() {
self.data = NSMutableDictionary()
super.init()
}
required init(coder aDecoder: NSCoder) {
data = NSMutableDictionary()
super.init(coder: aDecoder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
self.data = NSMutableDictionary()
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Step 0 : Wire up the data source and delegate
self.delegate = self
self.dataSource = self
// Step 1 : Define some events
let title : NSString = NSLocalizedString("Add Swift Demo", comment: "")
let date : NSDate = NSDate(day: 9, month: 1, year: 2015)
let event : CKCalendarEvent = CKCalendarEvent(title: title, andDate: date, andInfo: nil)
// Step 2 : Add the events to the cache array
self.data[date] = [event]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
// MARK: - CKCalendarDataSource
func calendarView(calendarView: CKCalendarView!, eventsForDate date: NSDate!) -> [AnyObject]! {
return self.data.objectForKey(date) as [AnyObject]!
}
override func calendarView() -> CKCalendarView! {
return CKCalendarView()
}
}
" 安装 mbcalendarKit 。说明可以在这里找到https://github.com/MosheBerman/MBCalendarKit
我也认为问题出在 podfile 上,但这似乎不是问题。提前致谢。