2013-02-21 38 views
3

目前我已在我的tabBarViewControllers之一中實施了Kal日曆,並且佈局非常完美。我現在想要創建一個用戶點擊的按鈕,並且日曆會立即在每月日曆視圖中按鈕「今日」突出顯示當前日期。使用Kal日曆

佈局再次完美,但下面列出的最後一行代碼給出了問題。

 
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SecondViewController showAndSelectToday]: unrecognized selector sent to instance 0x927e6f0' 

這裏是我已經對我secondViewController類是UIViewController一個超所作的落實。

 
- (void)viewDidLoad 
{ 
    KalViewController *calendar = [[KalViewController alloc] init]; 
    [self.view addSubview:calendar.view]; 
    [self addChildViewController:calendar]; 
    [[self navigationController] initWithRootViewController:calendar]; 
    calendar.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Today" style:UIBarButtonItemStyleBordered target:self action:@selector(showAndSelectToday)]; 
} 

目標:給「今日」功能不通過應用程序委託,但一個獨立的類,像我secondViewController

注意:假日示例應用程序正是我想要的「今日」行爲,但假日示例項目實現了應用程序委託中的今日按鈕行爲。

回答

1

您需要將KalViewController存儲爲一個實例變量(假設_calendar),然後實現在您的secondViewController下面的方法:

- (void)showAndSelectToday 
{ 
    [_calendar showAndSelectDate:[NSDate date]]; 
} 
相關問題