如何自定义EKEventEditViewController

Eag*_*ver 7 iphone calendar ios eventkit

我EKEventEditViewController在我的应用程序中使用默认,我想自定义它,目前它显示默认的所有字段EKEventEditViewController,但我不想显示URL字段,也想添加时区字段.我可以这样做吗?如果是,那么请求我知道我该怎么做? 在此输入图像描述

gil*_*s88 4

你可以使用这段摘录:

1)使您的视图控制器成为 EKEventEditViewController 的委托

EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
addController.delegate = self;
Run Code Online (Sandbox Code Playgroud)

2)然后在你的视图控制器上实现它:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if ([viewController isKindOfClass:[UITableViewController class]]) {
        UITableView *tableView = ((UITableViewController *)viewController).tableView;

    for (NSInteger j = 0; j < [tableView numberOfSections]; ++j)
    {
        for (NSInteger i = 0; i < [tableView numberOfRowsInSection:j]; ++i)
        {
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];

            NSLog(@"cell => %@, row => %d, section => %d", cell.textLabel.text, i, j);

            if([cell.textLabel.text isEqualToString:@"Calendar"]) {
                [cell removeFromSuperview];
            } else if(j == 5) { // If URL Field
                [cell removeFromSuperview];
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

}

注意:我之前在另一个 Stackoverflow 答案中发现了这一点,并在我的项目中实现了它。我忘记了链接。希望这会有所帮助,并感谢我得到这个的原始答案。