我想按照這些說明,但現在我卡住了。如何連接委託和數據源?
在您的視圖控制器中: 爲TKCalendarMonthView添加一個插座。
@interface YourViewController() <TKCalendarMonthViewDataSource, TKCalendarMonthViewDelegate>
@property (weak, nonatomic) IBOutlet TKCalendarMonthView *calendarMonthView;
@end
在-viewDidLoad,連接TKCalendarMonthView的委託和數據源。請注意,你也可以做到這一點的故事板,如果你第一次添加的註釋IBOutlet中的委託和DataSource屬性在TKCalendarMonthView.h
@implementation YourViewController
...
- (void)viewDidLoad
{
[super viewDidLoad];
...
self.calendarMonthView.delegate = self;
self.calendarMonthView.dataSource = self;
我在我的項目,但加班這段代碼我運行它,我得到這個
#import "ViewController.h"
#import "TapkuLibrary.h"
#import "TKCalendarMonthView.h"
@interface ViewController() <TKCalendarMonthViewDataSource, TKCalendarMonthViewDelegate>
@property (weak, nonatomic) IBOutlet TKCalendarMonthView *calendarMonthView;
@end
@implementation ViewController Method
- (void)viewDidLoad {
[super viewDidLoad];
self.calendarMonthView.delegate = self;
self.calendarMonthView.dataSource = self;
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
它成功地加載,但然後停止,因爲calendarMonthView:marksFromDate:TODATE:「在協議 'TKCalendarMonthViewDataSource' 沒有實現
時I g否則我的問題是我如何連接我的viewDidLoad中的TKCalendarMonthView委託和數據源,因爲這是我沒有在指令中做的,因爲我不知道如何,我認爲這是什麼原因造成的。
謝謝你的時間!
看看下面的 「calendarMonthView:TODATE:marksFromDate」:用戶界面連接到代碼](https://developer.apple.com/library /ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/chapters/edit_user_interface.html#//apple_ref/doc/uid/TP40010215-CH6-SW3),這將使您在正確的軌道上。我還建議查看[Ray Wenderlich](http://www.raywenderlich.com/)獲取一些基本的故事板教程 –
Command +單擊「TKCalendarMonthViewDataSource」並在.h中查看'calendarMonthView:marksFromDate:toDate'方法。文件。您需要在班級中實施此方法。 –
我Command +點擊'TKCalendarMonthViewDataSource',它把我帶到.h文件並突出顯示'@protocol TKCalendarMonthViewDataSource'。如何在.h文件中實現'calendarMonthView:marksFromDate:toDate'? @WorldOfWarcraft –