MBCalendarKit在基本选项卡式应用程序中显示黑屏

时间:2015-12-22 02:47:50

标签: swift viewcontroller mbcalendarkit

我对swift& amp; Xcode和我在XCode中使用基本的“选项卡式”应用程序模板,我正在尝试实现MBCalendarKit以在第一个选项卡视图上显示日历。我正在使用Cocoapods作为MBCalendar工具包。 Basic选项卡式应用程序以以下文件开头:

files

MBCalendarKit的作者解释说:

“您可以显示CKCalendarView的实例。如果您想手动管理视图层次结构或更好地控制日历视图,请使用此实例。” :

 render: function() {
    return (
      <form onSubmit={this.props.onTextSubmit}>
       ...
      </form>
    );
  }

我还遵循了一些提供的示例代码,尽管其中大部分是在objective-c中。目前在运行程序时,在第一个选项卡视图中,我只是得到一个黑屏。我如何解决此问题以呈现日历本身?我还查看了stackoverflow上的其他CalendarKit帖子,但似乎没有解决像这样具体的东西。

我的FirstViewController.swift(基本上与作者提供的相同):

/*
Here's how you'd show a CKCalendarView from within a view controller. 
It's just four easy steps.
*/

// 0. In either case, import CalendarKit:
#import "CalendarKit/CalendarKit.h"

// 1. Instantiate a CKCalendarView
CKCalendarView *calendar = [CKCalendarView new];

// 2. Optionally, set up the datasource and delegates
[calendar setDelegate:self];
[calendar setDataSource:self];

// 3. Present the calendar 
[[self view] addSubview:calendar];

和AppDelegate.swift:

import UIKit
import MBCalendarKit

class FirstViewController: CKCalendarViewController, CKCalendarViewDataSource {

    var data : NSMutableDictionary

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

        // Do any additional setup after loading the view.

        //  Step 0 : Wire up the data source and delegate
        self.delegate = self
        self.dataSource = self

        //  Step 1 : Define some test events
        let title : NSString = NSLocalizedString("Some random event", comment: "")
        let date : NSDate = NSDate(day: 20, month: 12, year: 2015)
        let event : CKCalendarEvent = CKCalendarEvent(title: title as String, andDate: date, andInfo: nil)

        //  Step 2 : Add the events to the cache array
        self.data[date] = [event]

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    //
    //  MARK: - CKCalendarDataSource
    //

    func calendarView(calendarView: CKCalendarView!, eventsForDate date: NSDate!) -> [AnyObject]! {

        return self.data.objectForKey(date) as! [AnyObject]!
    }

    /*
    // 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.
    }
    */

}

同样在AppDelegate文件中创建FirstViewController()时,我对nibName和bundle参数有点不确定。如果有人可以解释这个,因为我试图在Apples参考文档中查找它,但它仍然不清楚,并且对于所有我知道的事实,我两个都没有可能是我的问题?如果有人有使用CalendarKit的经验,或者可以帮助我,那就太好了,

干杯

0 个答案:

没有答案