我正在 iOS5 中开发 EKEvent。我可以添加、删除、列出事件,但现在的问题是当我尝试编辑现有事件时,“完成”按钮会产生问题。它不会进入 eventEditViewController: 方法。可能是什么问题?任何帮助将不胜感激。取消和删除按钮正在工作。当我编辑事件并单击“完成”时,控制台显示
Calendar: unable to save: (null)
.
这是我尝试过的代码..
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
EKEventEditViewController* eventViewController = [[EKEventEditViewController alloc] init];
event = [self.events objectAtIndex:indexPath.row];
eventViewController.event = event;
eventViewController.editViewDelegate = self;
[self presentModalViewController: eventViewController animated:YES];
[eventViewController release];
}
-(void)eventEditViewController:(EKEventEditViewController *)controller
didCompleteWithAction:(EKEventEditViewAction)action {
EKEvent *thisEvent = controller.event;
NSError *error;
if ([controller.event.endDate isEqualToDate:controller.event.startDate]) {
controller.event.endDate = [controller.event.startDate dateByAddingTimeInterval:1.0]; // add one second
}
switch (action) {
case EKEventEditViewActionCancelled:
// User tapped "cancel"
NSLog(@"Canceled");
break;
case EKEventEditViewActionSaved:
NSLog(@"Saved");
[controller.eventStore saveEvent:controller.event span: EKSpanFutureEvents error:&error];
break;
case EKEventEditViewActionDeleted:
// User tapped "delete"
NSLog(@"Deleted");
// delete the event from event list
[self.events removeObject:thisEvent];
// delete the event from event store
[self.eventStore removeEvent:thisEvent span:EKSpanThisEvent error:nil];
// reload the tableView
[self.tableOutlet reloadData];
break;
default:
NSLog(@"Default");
break;
}
[self dismissModalViewControllerAnimated:YES];
}