EKEventEditViewController会冻结应用程序并在很长时间后加载

我在swift中有以下代码:

var eventController = EKEventEditViewController() eventController.editViewDelegate = self var store = EKEventStore() eventController.eventStore = store var event = EKEvent(eventStore: store) event.title = viewModel.roleName event.location = viewModel.location event.startDate = viewModel.startDate event.endDate = viewModel.endDate eventController.event = event var status = EKEventStore.authorizationStatusForEntityType(EKEntityTypeEvent) switch status { case .Authorized: self.setNavBarAppearanceStandard() dispatch_async(dispatch_get_main_queue(), { () -> Void in self.presentViewController(eventController, animated: true, completion: nil) }) case .NotDetermined: store.requestAccessToEntityType(EKEntityTypeEvent, completion: { (granted, error) -> Void in if granted == true { self.setNavBarAppearanceStandard() dispatch_async(dispatch_get_main_queue(), { () -> Void in self.presentViewController(eventController, animated: true, completion: nil) }) } }) case .Denied, .Restricted: UIAlertView(title: "Access Denied", message: "Permission is needed to access the calendar. Go to Settings > Privacy > Calendars to allow access for the Be Collective app.", delegate: nil, cancelButtonTitle: "OK").show() return } 

这非常简单。 它在模拟器上完美的工作。 但是,当您尝试在设备上运行代码时,整个用户界面将冻结,有时大约1分钟后,编辑事件视图控制器出现,有时甚至根本没有。

请帮忙。

经过一番挖掘后,我有一个经理来确定eventStore(EKEventStore)variables必须是一个实例variables或一个单例类中的全局variables。 如果它是一个本地variables,它将永远呈现视图控制器。 这可能是SDK上的一些优化问题。