【问题标题】:UIAlertView and Requesting Access to AddressbookUIAlertView 和请求访问地址簿
【发布时间】:2014-07-20 09:35:23
【问题描述】:
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) 警报视图。

我也觉得有些东西我不明白,这与调度和队列有关。

【问题讨论】:

    标签: ios uialertview addressbook uialertviewdelegate


    【解决方案1】:

    试试这个

    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
    }
    

    【讨论】:

    • 为什么要发贴而不是直接发代码? @toasted_flakes 这次很友好地为你做这件事,但将来,请在答案本身中发布代码。
    • 您的回答与我的问题完全无关。请再次检查我的问题和我的代码。
    • 什么?!我仍然卡住了,我不明白这种奇怪的行为
    猜你喜欢
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多