标签:
今天写代码遇到了要调用系统通讯录,看了一些博客发现写的都是获取通讯录的内容,而不是调用系统的界面.
分享一下自己写的代码
第一步:引入
#import <AddressBook/AddressBook.h> #import <AddressBookUI/AddressBookUI.h>
#pragma mark -- IBAction - (IBAction)buttonClicked:(id)sender { ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init]; peoplePicker.peoplePickerDelegate = self; [self presentViewController:peoplePicker animated:YES completion:nil]; }第三步:实现代理方法ABPeoplePickerNavigationControllerDelegate
#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 value = ABMultiValueCopyValueAtIndex(valuesRef,index); [self dismissViewControllerAnimated:YES completion:^{ self.textField.text = (__bridge NSString*)value; }]; }这里需要说明一下的是 这里提供的方法开始适用于iOS8
标签:
原文地址:http://blog.csdn.net/broccoliii/article/details/44964105