我无法使用 Eventkit 访问我设备的日历。我正在使用 EKEventEditViewController 来呈现用于添加日历条目的 View 。
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEventEditViewController *eventController = [[EKEventEditViewController alloc]init];
eventController.eventStore = eventStore;
eventController.editViewDelegate = self;
...
[self presentViewController:eventController animated:YES completion:nil];
这个在模拟器上工作正常但我得到以下 在手机上运行时出现错误消息 (iOS6):“此应用无权访问您的日历”
按照建议检查隐私设置根本不会显示我的应用程序的任何条目。
如何解决这个问题并授予访问权限?
最佳答案
您可以请求访问
EKEventStore *store = [[EKEventStore alloc] init];
if([store respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
/* This code will run when uses has made his/her choice */
}];
}
您还可以向 plist (NSCalendarsUsageDescription) 添加一个 key ,该 key 将在请求所述访问权限时显示一个字符串。
关于objective-c - Eventkit 无法访问日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13298590/