Search code examples
ioseventkit

I want to disable the URL and NOTES fields of EKEventEditViewController


I want to customize the EKEventEditViewController with making its URL and NOTES fields disable or removing it. As its the default interface of EKEventEditViewController. I am not able to customize it on myself, I googled a lot for that and can not found any of the feasible solution for this. Any one have worked with such a scenario.Please elaborate the issue.


Solution

  • In header file include <UINavigationControllerDelegate> delegate

    Set EKEventEditViewController delegate to self or YourCurrentView Controller and write UINavigationController delegate method as given below.

    -(void)performCalendarActivity
    {
        NSLog(@"perform calendar activity called ");
    
        EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];
        addController.eventStore = eventStore;
        addController.delegate=self;  //<---------------------------------- Must
        EKEvent *event=[EKEvent eventWithEventStore:eventStore];
    
        [event setCalendar:[eventStore defaultCalendarForNewEvents]];
        addController.event=event;
    
        [self presentViewController:addController animated:YES completion:nil];
        addController.editViewDelegate = self;
    }
    
    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
        if ([viewController isKindOfClass:[UITableViewController class]]) {
    
            UITableView *tblView=((UITableViewController*)viewController).tableView;
            tblView.backgroundColor=[UIColor redColor];
    
            //Here you got the tableView now you can change everthing related to tableView.................
    
            UITableViewCell *cell=[tblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:5]];
            cell.userInteractionEnabled=false;
    
            UITableViewCell *cell2=[tblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:4]];
            cell2.userInteractionEnabled=false;
        }
    }
    

    If you do not want to show them simply use

    cell.hidden=YES;
    cell2.hidden=YES;