如何将MBCalendarkit集成到我的Swift项目中?

如何将MBCalendarkit集成到我的Swift项目中?,swift,uinavigationcontroller,mbcalendarkit,Swift,Uinavigationcontroller,Mbcalendarkit,我正在开发一个基于日期的应用程序。我在Swift项目中实现了一个日历。它在ios8上工作得很好,但在ios7上不工作。我刚刚将MBCalendarKit集成到我的Swift项目中。ViewController中应该有一个日历视图。你可以从这个链接找到我的项目 这是我的基本代码。我认为应该有孩子家长导航问题。请帮我解决这个问题 class ViewController: UIViewController, CKCalendarViewDelegate, CKCalendarViewDataSour

我正在开发一个基于日期的应用程序。我在Swift项目中实现了一个日历。它在
ios8
上工作得很好,但在
ios7
上不工作。我刚刚将
MBCalendarKit
集成到我的Swift项目中。
ViewController
中应该有一个日历视图。你可以从这个链接找到我的项目 这是我的基本代码。我认为应该有孩子家长导航问题。请帮我解决这个问题

class ViewController: UIViewController, CKCalendarViewDelegate, CKCalendarViewDataSource {



var data : NSMutableDictionary
var calendar = CKCalendarViewController()
var newdata = CKCalendarView()

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()

    calendar.dataSource = self
    //        self .addChildViewController(calendar)
    //        self.view.addSubview(calendar.view)
    //        calendar .didMoveToParentViewController(self)
    //        targetController.view.superview.center = self.view.center;

    self.parentViewController?.presentViewController(calendar, animated: true, completion: nil)

    let title : NSString = NSLocalizedString("Add Swift Demo", comment: "")
    let date : NSDate = NSDate(day: 14, month: 4, year: 2016)
    let event : CKCalendarEvent = CKCalendarEvent(title: title as String, andDate: date, andInfo: nil)
    self.data[date] = [event]
}
func calendarView(calendarView: CKCalendarView, willSelectDate date: NSDate) {
    print("will select called")
}
func calendarView(calendarView: CKCalendarView, didSelectDate date: NSDate) {

    print("didselect date called")
    let ntview = noteview(nibName: "noteview", bundle: nil)
    self.navigationController?.pushViewController(ntview, animated: true)
    //self.navigationController?.popViewControllerAnimated(false)
}
func calendarView(calendarView: CKCalendarView!, eventsForDate date: NSDate!) -> [AnyObject]! {

    return self.data.objectForKey(date) as [AnyObject]!
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/

}

从版本5开始,MBCalendarKit需要iOS 8.0或更高版本。如果您正在寻找iOS 7支持,可以尝试将文件直接拖动到Xcode项目中

版本5为Swift集成添加了许多改进。我审核了代码的可空性,并在适当的地方添加了
NS\u SWIFT\u NAME()


免责声明:我编写并维护了MBCalendarKit。

什么东西在ios 7上不起作用?在ios 7中,我无法显示日历,但在ios 8中,它显示得非常好。甚至我也没有收到任何警告或错误。你检查过你正在使用的播客文件吗?它是否显示此-->平台:ios,“8.0”?而且,考虑到MB Calendar有这么多问题需要解决,您为什么要首先使用它呢。为什么不使用最新版本?-->