Ios UIAlertView并请求访问通讯簿
这里有一点我不明白,当提示用户授予访问权限时,如果他点击cancel,我不会显示我的第二个UIAlertView,即accessDenied警报视图 另外,我觉得有一些我不明白的事情与调度和队列有关 试试这个Ios UIAlertView并请求访问通讯簿,ios,uialertview,addressbook,uialertviewdelegate,Ios,Uialertview,Addressbook,Uialertviewdelegate,这里有一点我不明白,当提示用户授予访问权限时,如果他点击cancel,我不会显示我的第二个UIAlertView,即accessDenied警报视图 另外,我觉得有一些我不明白的事情与调度和队列有关 试试这个 if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) { ABAddressBookRequestAccessWithCompletion(addressBookRef,
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];
}
为什么要发布粘贴而不是直接发布代码@这一次,toasted_flakes很好地为您做了这件事,但在将来,请在答案中发布代码。您的答案与我的问题完全无关。。请再次检查我的问题和代码。有什么吗?!我还是被卡住了,我不理解这种奇怪的行为
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
}