// 调用系统通讯录需要遵循两个代理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]); }]; }
时间: 2024-10-29 10:46:26