1

我正在使用EKEventEditViewController允许将事件从我的应用程序添加到 iPhone 日历。这是目前我正在使用的代码:

    [self.store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (!granted) { return; }
        EKEvent *storedEvent = [EKEvent eventWithEventStore:self.store];
        storedEvent.title = self.selectedEvent.title;
        storedEvent.startDate = self.selectedEvent.date;
        storedEvent.endDate = [NSDate dateWithTimeInterval:60*60 sinceDate:self.selectedEvent.date];
        storedEvent.notes = self.selectedEvent.comments;
        [storedEvent setCalendar:[self.store defaultCalendarForNewEvents]];
        self.eventController.event = storedEvent;
        self.eventController.eventStore = self.store;
        self.eventController.editViewDelegate = self;
        [self presentViewController:self.eventController animated:YES completion:nil];
    }];

尽管我已经预先初始化了视图控制器和EventStore. 有没有办法让它更快,或者我只需要设置一个微调器并告诉用户等待?

4

1 回答 1

6

将在任意队列上调用完成处理程序。在主线程的完成块内调度 UIKit 相关的东西:

[[NSOperationQueue mainQueue] addOperationWithBlock:^{
    self.eventController.event = storedEvent;
    self.eventController.eventStore = self.store;
    self.eventController.editViewDelegate = self;
    [self presentViewController:self.eventController animated:YES completion:nil];
}];
于 2013-11-05T15:59:58.237 回答