开发者

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 pa开发者_如何学JAVAsting 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.


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.


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.


in this .m file you need to import the EventKit/EventKit.h and EventKitUI/EventKitUI.h and in the .h file you need to implement the 'EKEventViewDelegate' delegates.

hope it helps you


This does seem to be a fairly obvious omission in the library. My workaround: I'm presenting the EKEventViewController in a UINavigationController. I detect completion in the viewWillAppear method of the controller than pushed the EKEventViewController onto the view stack. Use a boolean variable in this view controller to track and differentiate between initial appearance and re-appearance due to the EKEventViewController being popped. There is a risk that your code will get called at other times, but if you are just refreshing tableviews, etc, then this should be sufficient.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜