Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EKEventViewDelegate didCompleteWithAction not getting called

I don't get a call to my eventViewController:didCompleteWithAction: when the EKEventViewController finishes edting an event.

Here's how I set it up:


- (void)showCalendar:(id)sender {
    EKEventViewController *eventViewController = [[EKEventViewController alloc] init];

    eventViewController.delegate = self;

    eventViewController.event = self.event;

    // Allow event editing.
    eventViewController.allowsEditing = YES;

    [self.navigationController pushViewController:eventViewController animated:YES];
    [eventViewController release];
}

I do have the protocol on my class and the method was implements by copy and pasting the definition from the docs. It just doesn't get called.

If I use the EKEventEditViewController and its corresponding delegate, then that does get called when the event is saved.

I was able to reproduce the problem in the SimpleEKDemo code same as well. Does anyone know what might be wrong?

I could just drop the view functionality and go straight to the EKEventEditViewController, but I'd rather not.

like image 316
Rob Avatar asked Jan 21 '11 03:01

Rob


2 Answers

Might be a bit late to be helpful, but I had this problem as well.

To get around it I subclassed EKEventViewController, then in the subclass' viewDidLoad I replaced the standard edit button with one of my own:


- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self.delegate action:@selector(editCalEvent)];

    self.navigationItem.rightBarButtonItem = editItem;
}


That way when you want to edit an event, you can set up your own EKEventEditViewController and specify its delegate in order to respond to changes:


- (void)editCalEvent {

    EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];

    editController.event = editingEvent;
    editController.eventStore = self.eventStore;
    editController.editViewDelegate = self;

    [self presentModalViewController:editController animated:YES];

    [editController release];

}


Hope that helps.

like image 65
browncow781 Avatar answered Oct 12 '22 23:10

browncow781


I had the similar problem when I use "pushViewController", the result is that it will go to

- (void)navigationController:(UINavigationController *)navigationController 
  willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{}

But after I changed to presentModalViewController, it will go to eventViewController:didCompleteWithAction: when Done/Cancel/Delete are pressed.

like image 25
jesse Avatar answered Oct 12 '22 23:10

jesse