iOS --调用系统通讯录

// 调用系统通讯录需要遵循两个代理ABPeoplePickerNavigationControllerDelegate,UINavigationControllerDelegate
相关类为ABPeoplePickerNavigationController
// 系统通讯录自带导航栏,所有要model出来
// 初始化
    ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
    peoplePicker.peoplePickerDelegate = self;
    [self presentViewController:peoplePicker animated:YES completion:nil];
#pragma mark - ABPeoplePickerNavigationControllerDelegate
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    
    ABMultiValueRef valuesRef = ABRecordCopyValue(person, kABPersonPhoneProperty);
    
    CFIndex index = ABMultiValueGetIndexForIdentifier(valuesRef,identifier);
    
    //电话号码
    
    CFStringRef telValue = ABMultiValueCopyValueAtIndex(valuesRef,index);
    //全名
    
    CFStringRef anFullName = ABRecordCopyCompositeName(person);
    
    [self dismissViewControllerAnimated:YES completion:^{
        
//        (__bridge NSString *)telValue;
//        [NSString stringWithFormat:@"%@",anFullName];


        NSLog(@"%@---%@",(__bridge NSString *)telValue,[NSString stringWithFormat:@"%@",anFullName]);
        
    }];
    

}

 

posted @ 2016-05-02 21:42  Colaless  阅读(564)  评论(0编辑  收藏  举报