EKEventEditViewController

EKEventEditViewController

本文介绍了如何自定义 EKEventEditViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用默认 EKEventEditViewController,我想自定义它,目前它显示默认 EKEventEditViewController 中的所有字段,但我不想显示 URL 字段并且还想添加时区字段.我可以这样做吗?如果可以,请告诉我该怎么做?

I am using default EKEventEditViewController in my App and I want to customize it, currently it shows all fields that came in default EKEventEditViewController, but I don't want to show URL field and also want to add Timezone field. Can I do that and if yes then pleas let me know how can I do this?

推荐答案

你可以使用这段摘录:

1) 让您的视图控制器成为您的 EKEventEditViewController 的代表

1) make your viewcontroller the delegate of your EKEventEditViewController

EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
addController.delegate = self;

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

2) then implement this on your view controller:

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

}

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

Note: I found this in another Stackoverflow answer before and implemented it on my project. I forgot the link. Hope this helps and thanks to the original answer where I got this.

这篇关于如何自定义 EKEventEditViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 02:08