Ber*_*rnd 1 permissions calendar objective-c ios eventkit
我无法使用Eventkit访问设备的日历.我正在使用EKEventEditViewController来呈现用于添加日历条目的视图.
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEventEditViewController *eventController = [[EKEventEditViewController alloc]init];
eventController.eventStore = eventStore;
eventController.editViewDelegate = self;
...
[self presentViewController:eventController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
这在模拟器上工作正常,但在手机上运行它时会收到以下错误消息(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 */
}];
}
Run Code Online (Sandbox Code Playgroud)
您还可以向plist(NSCalendarsUsageDescription)添加一个键,该键将在请求所述访问时显示字符串.
| 归档时间: |
|
| 查看次数: |
2626 次 |
| 最近记录: |