1

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];

これはシミュレーターでは正常に機能しますが、電話(iOS6)で実行すると、次のエラーメッセージが表示されます: 「このアプリはカレンダーにアクセスできません」

このアプリはあなたのカレンダーにアクセスできません

アドバイスに従ってプライバシー設定を確認しても、アプリのエントリはまったく表示されません。

これを解決してアクセスを許可するにはどうすればよいですか?

4

1 に答える 1

6

アクセスをリクエストできます

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)にキーを追加して、アクセスを要求したときに文字列を表示することもできます。

于 2012-11-08T22:17:15.120 に答える