gpt4 book ai didi

iphone - EKEventEditViewActionDeleted 在删除事件时多次调用

转载 作者:行者123 更新时间:2023-12-03 20:07:50 24 4
gpt4 key购买 nike

我正在尝试将事件保存到 iPhone 日历中,以便在用户删除该事件时也将其删除。以下是我用于创建和编辑事件的代码。

// Upon selecting an event, create an EKEventViewController to display the event.
EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];
editController.event = [eventsList objectAtIndex:indexPath.row];
editController.eventStore = self.eventStore;
editController.editViewDelegate = self;
itsSelectedReminder = indexPath.row;
isReminderDeleted = TRUE;
[editController.navigationBar setTintColor:[UIColor colorWithRed:67/255.0 green:114/255.0 blue:18/255.0 alpha:1]];
[self presentModalViewController:editController animated:YES];

[editController release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];

然后,当用户执行任何添加、编辑或删除操作时,我将使用以下代码捕获该事件。

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

它非常适合添加和编辑,但是当我尝试删除时,它会多次调用该方法,从而使我的应用程序崩溃。任何帮助是极大的赞赏。请尽快提供帮助。

提前致谢

问候,

迪利普...

最佳答案

完成后立即将 Controller 的 editViewDelegate 设置为 nil。

func eventEditViewController(controller: EKEventEditViewController, didCompleteWithAction action: EKEventEditViewAction) {

// prevent additional calls for the same action
controller.editViewDelegate = nil

// whatever else you want to do
dismissViewControllerAnimated(true) {
}
...
}

关于iphone - EKEventEditViewActionDeleted 在删除事件时多次调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8050957/

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