0
- (void)eventEditViewController:(EKEventEditViewController *)controller 
        didCompleteWithAction:(EKEventEditViewAction)action {

    NSError *error = nil;
    EKEvent *thisEvent = controller.event;

    switch (action) {
        case EKEventEditViewActionCanceled:
            // Edit action canceled, do nothing. 
            break;

        case EKEventEditViewActionSaved:
            // When user hit "Done" button, save the newly created event to the event store, 
            // and reload table view.
            // If the new event is being added to the default calendar, then update its 
            // eventsList.
            if (self.defaultCalendar ==  thisEvent.calendar) {
                [self.eventsList addObject:thisEvent];
            }
            [controller.eventStore saveEvent:controller.event span:EKSpanFutureEvents error:&error];
            [self.tableView reloadData];
            break;

        case EKEventEditViewActionDeleted:
            // When deleting an event, remove the event from the event store, 
            // and reload table view.
            // If deleting an event from the currenly default calendar, then update its 
            // eventsList.
            if (self.defaultCalendar ==  thisEvent.calendar) {
                [self.eventsList removeObject:thisEvent];
            }
            [controller.eventStore removeEvent:thisEvent span:EKSpanFutureEvents error:&error];
            [self.tableView reloadData];
            break;

        default:
            break;
    }
    // Dismiss the modal view controller
    [controller dismissModalViewControllerAnimated:YES];

}

这个函数在 EKEventEditViewDelegate. 我想知道当我单击“动作”值是哪个按钮时EKEventEditViewActionDeleted在此处输入图像描述

起初,我认为当我单击删除事件按钮时,action == EKEventEditViewActionDeleted. 但不是。任何人都可以帮助我吗?

4

1 回答 1

0

Implement the EKEventViewDelegate protocol then check for the delete event with...

-(void) eventViewController:(EKEventViewController *)controller didCompleteWithAction:(EKEventViewAction)action
{
    if (action == EKEventViewActionDeleted) {
        // Update unique event ID to core data & change text of button to new
        _itemReminder = NULL;
        _part.reminderID = NULL;
        _savedEventFound = NO;
        [_reminderButton  setTitle: @"New" forState: UIControlStateNormal];

    }
}
于 2013-12-07T13:33:37.280 回答