EKEventViewDelegate didCompleteWithAction 没有被调用
当 EKEventViewController 完成事件编辑时,我没有收到对 eventViewController:didCompleteWithAction: 的调用。
我的设置方式如下:
- (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];
}
我的类上确实有协议,并且该方法是通过复制并粘贴文档中的定义来实现的。它只是没有被调用。
如果我使用 EKEventEditViewController 及其相应的委托,那么在保存事件时就会调用它。
我也能够在 SimpleEKDemo 代码中重现该问题。有谁知道可能出了什么问题?
我可以放弃视图功能并直接转到 EKEventEditViewController,但我不愿意。
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 pasting 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可能有点晚了,但我也遇到了这个问题。
为了解决这个问题,我对
EKEventViewController
进行了子类化,然后在子类的viewDidLoad
中,我用我自己的按钮替换了标准编辑按钮:这样,当您想要编辑时一个事件,您可以设置自己的
EKEventEditViewController
并指定其委托以响应更改:希望有帮助。
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: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:Hope that helps.
当我使用“pushViewController”时,我遇到了类似的问题,结果是它会转到
但是当我更改为
presentModalViewController
后,它会转到eventViewController:didCompleteWithAction:
时按下完成/取消/删除。I had the similar problem when I use "pushViewController", the result is that it will go to
But after I changed to
presentModalViewController
, it will go toeventViewController:didCompleteWithAction:
when Done/Cancel/Delete are pressed.在此 .m 文件中,您需要导入 EventKit/EventKit.h 和 EventKitUI/EventKitUI.h
在 .h 文件中,您需要实现“EKEventViewDelegate”委托。
希望对你有帮助
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
这似乎是图书馆中一个相当明显的遗漏。我的解决方法:我在 UINavigationController 中呈现 EKEventViewController。我在控制器的 viewWillAppear 方法中检测到完成,然后将 EKEventViewController 推送到视图堆栈上。在此视图控制器中使用布尔变量来跟踪和区分由于 EKEventViewController 被弹出而导致的初始外观和重新外观。存在您的代码在其他时间被调用的风险,但如果您只是刷新表格视图等,那么这应该足够了。
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.