获得联系人许可后,应用会冻结6-10秒

时间:2014-08-07 17:20:27

标签: ios ios7 abaddressbook

在进入"导入联系人"之前,我要求用户提供联系人权限。查看控制器。当我点击“是”以获得许可请求时,应用程序将暂停约5-10秒,然后继续执行segue。在该冻结时间内,它不允许任何用户交互或其他任何进展。

经批准后采取的行动是

NSLog(@"Just authorized");

[self.navigationController pushViewController:vc animated:YES];

- (void)getAddressBookPermission:(EIConnectionsImportContactsTableViewController *)vc {
    if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusDenied ||
        ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusRestricted){
        //1
        UIAlertView *permissionDeniedAlert = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"Permission Denied - We're unable to import contacts from your phone unless you provide approval."  delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [permissionDeniedAlert show];

    } else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized){
        //2
        [self.navigationController pushViewController:vc animated:YES];
    } else { //ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined
        ABAddressBookRequestAccessWithCompletion(ABAddressBookCreateWithOptions(NULL, nil), ^(bool granted, CFErrorRef error) {
            if (!granted){
                //4
                UIAlertView *permissionDeniedAlert = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"Permission Denied - We're unable to import contacts from your phone unless you provide approval."  delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
                [permissionDeniedAlert show];
                return;
            }
            NSLog(@"Just authorized");
            [self.navigationController pushViewController:vc animated:YES];
        });
    }
}

停滞的任何可识别原因?

0 个答案:

没有答案