gpt4 book ai didi

ios - EKEvent 编辑不起作用

转载 作者:行者123 更新时间:2023-12-01 17:23:49 25 4
gpt4 key购买 nike

我正在 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];

}

最佳答案

根据docs ,

eventStore

This property must be set before displaying the view.


所以,
eventViewController.eventStore = <your event store>;
eventViewController.editViewDelegate = self;

[self presentModalViewController: eventViewController
animated: YES];

关于ios - EKEvent 编辑不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10832394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com