简体   繁体   English

使用Kal日历

[英]Working with the Kal calendar

Currently I have implemented the Kal calendar within one of my tabBarViewControllers and the layout is perfect. 目前我已经在我的一个tabBarViewControllers实现了Kal日历,并且布局非常完美。 I now want to create a button that the user clicks and the calendar instantly highlights the current day in the a monthly calendar view, the button "Today". 我现在想要创建一个用户点击的按钮,日历会立即突出显示每月日历视图中的当前日期,即“今天”按钮。

The layout is again perfect, but the last line of code listed below gives problems. 布局再次完美,但下面列出的最后一行代码给出了问题。

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

Here is all the implementation I have made to my secondViewController class that is a superclass of UIViewController . 这是我对我的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)];
}

Goal: Give "today" functionality NOT THROUGH THE APP DELEGATE but a seperate class, like my secondViewController . 目标:提供“今天”功能,而不是通过APP DELEGATE但是一个单独的类,比如我的secondViewController

Note: The holiday example app is exactly what I would like for "Today" to behave but the holiday example project implements the today button behaviors within the app delegate. 注意:假日示例应用程序正是我希望“今天”的行为,但假日示例项目实现了应用程序委托中的今日按钮行为。

You need to store the KalViewController as an instance variable (let's assume _calendar) and then implement the following method in your secondViewController: 您需要将KalViewController存储为实例变量(让我们假设_calendar),然后在secondViewController中实现以下方法:

- (void)showAndSelectToday
{
    [_calendar showAndSelectDate:[NSDate date]];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM