Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

iphone - How to customise EKEventEditViewController

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? enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you can use this excerpt:

1) make your viewcontroller the delegate of your EKEventEditViewController

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

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

}

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...