简体   繁体   English

更改日历时未保存 EKEventEditViewController 更改

[英]EKEventEditViewController changes not saved when changing calendar

When editing an event on an instance of EKEventEditViewController and selecting another calendar, the calendar on the event does change, but the changes to other attributes like the title get lost.在 EKEventEditViewController 实例上编辑事件并选择另一个日历时,事件上的日历确实会发生变化,但对标题等其他属性的更改会丢失。

If I don't select another calendar the changes are persisted as expected.如果我不选择另一个日历,则更改会按预期保留。

This is my code when loading up the editor这是我加载编辑器时的代码

let editorVC = EKEventEditViewController()
eventKitEditorViewController = editorVC // eventKitEditorViewController is a class variable

editorVC.event = ekEvent // ekEvent is the supplied event to edit
editorVC.modalPresentationStyle = .Popover
editorVC.eventStore = OP1EventKitManager.sharedInstance.eventStore // the store is on a singleton object
editorVC.editViewDelegate = self

rootVC.presentViewController(editorVC, animated: true, completion: nil)

/// DELEGATE METHOD

    func eventEditViewController(controller: EKEventEditViewController, didCompleteWithAction action: EKEventEditViewAction) {
        print(action)
        controller.dismissViewControllerAnimated(true, completion: nil)
    }

Do I need to do anything extra when the eventEditViewController didCompleteWithAction is completed?当 eventEditViewController didCompleteWithAction 完成时,我需要做任何额外的事情吗?

In your callback, you are not saving the event.在您的回调中,您没有保存事件。 try saving your event in the callback and see if that fixes the problem.尝试在回调中保存您的事件,看看是否能解决问题。 something similar to this:类似的东西:

let event = controller.event!

 do {
     try eventStore.saveEvent(event, span: .ThisEvent, commit: true)
 } catch {
     print("Could not update the event store with supplied changes")
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用EKEventEditViewController创建带闹钟的日历事件 - Creating a calendar event with an alarm using EKEventEditViewController Swift:EKEventEditViewController 中没有显示日历和错误消息(没有崩溃) - Swift: No Calendar showing up in EKEventEditViewController and error message (no crash) 添加被邀请者时,EKEventEditViewController SGErrorDomain代码= 8 - EKEventEditViewController SGErrorDomain code=8 when adding Invitees 使用rubymotion时未初始化的常量EKEventEditViewController(NameError) - uninitialized constant EKEventEditViewController (NameError) when using rubymotion 选择其他日历时,EKEvent标识符会更改 - EKEvent identifier changes when selecting another calendar EventKit:出现EKEventEditViewController实例时出错,然后在位置编辑后崩溃 - EventKit: error when an instance of EKEventEditViewController presented, then a crash after location edit 这是EKEventEditViewController的错误吗 - Is this a bug for EKEventEditViewController iOS NSManagedObjectContext-保存所有更改后是否可以获取或发送通知? - iOS NSManagedObjectContext - is it possible to get or send a notification when all changes is saved? 分段控件更改时更改视图控制器 - Changing view controller when Segmented Control changes 设备方向更改时更改视图控制器 - changing view controller when the device orientation changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM