OK
ユーザーがAddressBook パーミッションを押すたびに、UIAlertView
これらのコマンドの実行に遅延が生じることを除けば、すべてうまくいきますNSLog
。
同じコードは、カレンダーのアクセス許可で即座に機能します。
誰かがここで私を助けてくれますか? ありがとうございました。
遅延(5秒)後に実行されているコード
NSLog(@"Granted!");
_1234.backgroundColor = [UIColor lightGrayColor]; [_12345 setHidden:NO]; [ _qwerty setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [_qwerty1 setHidden:YES];
完全な機能
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool 付与, CFErrorRef エラー) {
もし(エラー)
{ // display error message here }
そうでなければ (!granted)
{ // display access denied error message here } else { NSLog(@"Granted!"); //this gets printed instantly _qwerty.userInteractionEnabled = NO; _1234.backgroundColor = [UIColor lightGrayColor]; [_12345 setHidden:NO]; [ _qwerty setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; [_qwerty1 setHidden:YES]; [self qwerty4]; } }); }