gpt4 book ai didi

iphone - 使用 Kal 日历

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:22:47 24 4
gpt4 key购买 nike

目前,我已经在我的一个 tabBarViewControllers 中实现了 Kal 日历,而且布局非常完美。我现在想创建一个按钮,用户单击该按钮,日历会立即在月历 View 中突出显示当前日期,即按钮“今天”。

布局再次完美,但下面列出的最后一行代码出现问题。

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

这是我对 secondViewController 类所做的所有实现,它是 UIViewController 的父类(super class)。

- (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)];}

目标:不通过 APP DELEGATE 而是通过单独的类提供“今天”的功能,例如我的 secondViewController

注意:假日示例应用正是我希望“今天”的行为,但假日示例项目在应用委托(delegate)中实现了今天按钮的行为。

最佳答案

您需要将 KalViewController 存储为实例变量(假设为 _calendar),然后在您的 secondViewController 中实现以下方法:

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

关于iphone - 使用 Kal 日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14997752/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com