if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
if (granted) {
// First time access has been granted, add the contact
[self prepareContactsIDs];
} else {
UIAlertView *accessDenied = [[UIAlertView alloc] initWithTitle:@"Need Access to Addressbook" message:@"KeepItClean requires an access to addressbook in order to be usable" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[accessDenied show];
}
});
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
if ([self isFirstRun]) {
[self prepareContactsIDs];
}
}
else {
// The user has previously denied access
// Send an alert telling user to change privacy setting in settings app
UIAlertView *accessDenied = [[UIAlertView alloc] initWithTitle:@"Need Access to Addressbook" message:@"KeepItClean requires an access to addressbook in order to be usable" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[accessDenied show];
}
我不明白这里有什么东西,当提示用户提供访问权限时,如果他点击取消,我就不会显示我的第二个UIAlertView,(accessDenied)警报视图。< / p>
此外,我觉得有些事情我不了解与调度和队列有关。
答案 0 :(得分:0)
试试这个
ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
peoplePicker.peoplePickerDelegate= self;
ABAddressBookRef UsersAddressBook = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus()!= kABAuthorizationStatusDenied)
{
//Show alert of access
}
else
{
//Show alert of access denied
}