EKEventViewDelegate didCompleteWithAction 没有被调用

发布于 2024-10-12 19:38:28 字数 764 浏览 1 评论 0原文

当 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

海拔太高太耀眼 2024-10-19 19:38:28

可能有点晚了,但我也遇到了这个问题。

为了解决这个问题,我对 EKEventViewController 进行了子类化,然后在子类的 viewDidLoad 中,我用我自己的按钮替换了标准编辑按钮:


- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self.delegate action:@selector(editCalEvent)];

    self.navigationItem.rightBarButtonItem = editItem;
}

这样,当您想要编辑时一个事件,您可以设置自己的 EKEventEditViewController 并指定其委托以响应更改:


- (void)editCalEvent {

    EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];

    editController.event = editingEvent;
    editController.eventStore = self.eventStore;
    editController.editViewDelegate = self;

    [self presentModalViewController:editController animated:YES];

    [editController release];

}

希望有帮助。

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:


- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self.delegate action:@selector(editCalEvent)];

    self.navigationItem.rightBarButtonItem = editItem;
}

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:


- (void)editCalEvent {

    EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];

    editController.event = editingEvent;
    editController.eventStore = self.eventStore;
    editController.editViewDelegate = self;

    [self presentModalViewController:editController animated:YES];

    [editController release];

}

Hope that helps.

記柔刀 2024-10-19 19:38:28

当我使用“pushViewController”时,我遇到了类似的问题,结果是它会转到

- (void)navigationController:(UINavigationController *)navigationController 
  willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{}

但是当我更改为 presentModalViewController 后,它会转到 eventViewController:didCompleteWithAction: 时按下完成/取消/删除。

I had the similar problem when I use "pushViewController", the result is that it will go to

- (void)navigationController:(UINavigationController *)navigationController 
  willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{}

But after I changed to presentModalViewController, it will go to eventViewController:didCompleteWithAction: when Done/Cancel/Delete are pressed.

谈下烟灰 2024-10-19 19:38:28

在此 .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

夏尔 2024-10-19 19:38:28

这似乎是图书馆中一个相当明显的遗漏。我的解决方法:我在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文