ios - 更改日历时未保存 EKEventEditViewController 更改

标签 ios eventkit ekevent ekeventstore

当在 EKEventEditViewController 实例上编辑事件并选择另一个日历时,事件上的日历会发生变化,但对其他属性(如标题)的更改会丢失。

如果我不选择其他日历,更改将按预期保留。

这是我加载编辑器时的代码

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)
    }

当 eventEditViewController didCompleteWithAction 完成时,我是否需要做任何额外的事情?

最佳答案

在您的回调中,您没有保存事件。尝试在回调中保存您的事件,看看是否能解决问题。类似这样的东西:

let event = controller.event!

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

关于ios - 更改日历时未保存 EKEventEditViewController 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36118153/

相关文章:

ios - MVC iOS - 表格 View 单元格

ios - 如何获取包含子层的 View 的屏幕截图?

macos - 请求 EventKit 访问 macOS SwiftUI

iphone - 获取 EkEvent 的日历颜色引用

iphone - XCode 4 - 通用应用程序 - 使用选项卡栏 Controller 时 View 不会改变

ios - 取消 UNNotificationRequest

iphone - EKAlarm 绝对日期为空

ios - 如果 iCloud 设置为不同步提醒,则无法创建本地 EKCalendar(提醒)

ios - iOS 上带有 eventWithIdentifier 的 EKEvent

ios - 在 EKEvent 中为 iCal 设置特定的事件日期