首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eventkit无法访问日历

Eventkit无法访问日历
EN

Stack Overflow用户
提问于 2012-11-08 22:01:33
回答 1查看 2.7K关注 0票数 1

我无法使用Eventkit访问设备的日历。我使用一个EKEventEditViewController来显示一个添加日历条目的视图。

代码语言:javascript
复制
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEventEditViewController *eventController = [[EKEventEditViewController alloc]init]; 
eventController.eventStore = eventStore;
eventController.editViewDelegate = self;

...

[self presentViewController:eventController animated:YES completion:nil];

在模拟器上运行良好,但我在电话(IOS6)上运行它时会收到以下错误消息:“此应用程序无法访问日历”

按建议检查隐私设置不会显示我的应用程序的任何条目。

如何解决这一问题并授予访问权?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-08 22:17:15

您可以请求访问

代码语言:javascript
复制
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)添加一个键,该键将在请求所述访问时显示字符串。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13298590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档