调用iPhone通信录的

占坑app

 

 

ABPeoplePickerNavigationController *peoleVC = [[ABPeoplePickerNavigationController alloc] init];ide

    peoleVC.peoplePickerDelegate = self;orm

    peoleVC.delegate = self;索引

    [self presentViewController:peoleVC animated:YES completion:nil];ci

    

    // 设置标题导航栏的颜色string

    if ([[[UIDevice currentDevice] systemVersion] floatValue]>=9.0){it

        [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];io

    }else{table

        [[UINavigationBar appearanceWhenContainedIn:[ABPeoplePickerNavigationController class], nil] setTintColor:[UIColor blackColor]];class

    }

 

 

===========================================================================================

 

#pragma mark - ABPeoplePickerNavigationControllerDelegate

-(BOOL) peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{

    NSString *name = (__bridge NSString *)ABRecordCopyCompositeName(person);

    NSString *phone;

    

    //判断点击的区域

    if (property == kABPersonPhoneProperty)

    {

        //取出当前点击的区域中全部的内容

        ABMutableMultiValueRef phoneMulti =  ABRecordCopyValue(person,kABPersonPhoneProperty);

        //根据点击的那一行对应的identifier取出所在的索引

        long index =  ABMultiValueGetIndexForIdentifier(phoneMulti, identifier);

        //根据索引把相应的值取出

        phone =  (__bridge NSString *)ABMultiValueCopyValueAtIndex(phoneMulti, index);

        

        ZW_DEBUG_Log(@"******************>>>>%@",phone);

    }

    

//    LRAddPhoneUrgencyCell *phoneCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];

//    phoneCell.textFld.text = [NSString stringWithFormat:@"%@",phone];

    if (phone) {

        phone = [phone stringByReplacingOccurrencesOfString:@"-" withString:@""];

    }

    

    [self setUserNameFldText:[NSString stringWithFormat:@"%@",phone] withPhoneZone:phoneZone];

    LRAddPhoneUrgencyCell *nameCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];

    nameCell.textFld.text = [NSString stringWithFormat:@"%@",name];

    

    [peoplePicker dismissViewControllerAnimated:YES completion:nil];

    

    return NO;

}

 

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker{

    [peoplePicker dismissViewControllerAnimated:YES completion:nil];

}

 

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker

                         didSelectPerson:(ABRecordRef)person

                                property:(ABPropertyID)property

                              identifier:(ABMultiValueIdentifier)identifier{

    NSString *name = (__bridge NSString *)ABRecordCopyCompositeName(person);

    NSString *phone;

    

    //判断点击的区域

    if (property == kABPersonPhoneProperty)

    {

        //取出当前点击的区域中全部的内容

        ABMutableMultiValueRef phoneMulti =  ABRecordCopyValue(person,kABPersonPhoneProperty);

        //根据点击的那一行对应的identifier取出所在的索引

        long index =  ABMultiValueGetIndexForIdentifier(phoneMulti, identifier);

        //根据索引把相应的值取出

        phone =  (__bridge NSString *)ABMultiValueCopyValueAtIndex(phoneMulti, index);

        

        ZW_DEBUG_Log(@"******************>>>>%@",phone);

    }

    

//    LRAddPhoneUrgencyCell *phoneCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];

    //    phoneCell.textFld.text = [NSString stringWithFormat:@"%@",phone];

 

    if (phone) {

        phone = [phone stringByReplacingOccurrencesOfString:@"-" withString:@""];

    }

    [self setUserNameFldText:[NSString stringWithFormat:@"%@",phone] withPhoneZone:phoneZone];

 

    LRAddPhoneUrgencyCell *nameCell = [_tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];

    nameCell.textFld.text = [NSString stringWithFormat:@"%@",name];

}

相关文章
相关标签/搜索