我的应用程序的一部分需要日历访问,这需要从 iOS 7 开始调用该EKEventStore
方法-(void)requestAccessToEntityType:(EKEntityType)entityType completion:(EKEventStoreRequestAccessCompletionHandler)completion
。
我添加了请求,如果用户选择允许访问,一切都会顺利进行,但是如果用户拒绝或之前拒绝访问,则会出现问题。如果访问被拒绝,我添加了一个UIAlertView
通知用户,但UIAlertView
始终需要 20-30 秒才能出现,并在此期间完全禁用 UI。调试表明它[alertView show]
在延迟之前运行,即使它实际上直到延迟之后才显示。
为什么会发生这种延迟,我该如何消除它?
[eventStore requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *error) {
if (granted) {
[self createCalendarEvent];
} else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Calendar Access Denied"
message:@"Please enable access in Privacy Settings to use this feature."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}];