How to customise EKEventEditViewController

前端 未结 1 812
无人共我
无人共我 2020-12-16 23:46

I am using default EKEventEditViewController in my App and I want to customize it, currently it shows all fields that came in default EKEventEditViewContr

相关标签:
1条回答
  • 2020-12-17 00:31

    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.

    0 讨论(0)
提交回复
热议问题