iOS如何获取系统通讯录信息
1.简介
Address Book:作为提供将用户通讯录和用户信息存储在iOS设备的集中式数据库
2.使用
首先倒入AddressBookUI/AddressBookUI.h
其次创建对象
ABPeoplePickerNavigationController *abPicker = [[ABPeoplePickerNavigationController alloc]init];
设置代理abPicker.peoplePickerDelegate = self;
注意:在iOS系统大于8.0情况下需要做一个判断
abPicker.predicateForSelectionOfPerson = [NSPredicate predicateWithValue:false];
3.获取用户名.手机号码.头像
-(void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
用户名
NSString* lastName = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonLastNameProperty);
头像
NSData *imageData = (__bridge NSData*)ABPersonCopyImageData(person);
UIImage *image = [UIImage imageWithData:imageData];
手机号码
if (property == kABPersonPhoneProperty) {
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
NSString* phone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneProperty,identifier);
}
}
4.显示并且编辑联系人
5.创建联系人
6.删除联系人..........