#pragma mark - ABPeoplePickerNavigationControllerDelegate
- (void)onChooseContact{
UIImage *navigationBarImage = [UIImage imageNamed:@"navigationBarBG.png"];
navigationBarImage = [ARWImageUtil scaleToSize:navigationBarImage size:CGSizeMake(320, 64)];
[[UINavigationBar appearance] setBackgroundImage:navigationBarImage forBarMetrics:UIBarMetricsDefault];
[self presentViewController:_peoplePicker animated:YES completion:^(void){}];
}
//ios7 =< version <ios8以下,不包含ios8
#if (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED < 80000)
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
// ABMutableMultiValueRef address=ABRecordCopyValue(person, kABPersonAddressProperty);
// ABMutableMultiValueRef birthday=ABRecordCopyValue(person, kABPersonBirthdayProperty);
// ABMutableMultiValueRef creationDate=ABRecordCopyValue(person, kABPersonCreationDateProperty);
// ABMutableMultiValueRef date=ABRecordCopyValue(person, kABPersonDateProperty);
// ABMutableMultiValueRef department=ABRecordCopyValue(person, kABPersonDepartmentProperty);
// ABMutableMultiValueRef email=ABRecordCopyValue(person, kABPersonEmailProperty);
// ABMutableMultiValueRef firstNamePhonetic=ABRecordCopyValue(person, kABPersonFirstNamePhoneticProperty);
// ABMutableMultiValueRef firstName=ABRecordCopyValue(person, kABPersonFirstNameProperty);
// ABMutableMultiValueRef instantMessage=ABRecordCopyValue(person, kABPersonInstantMessageProperty);
// ABMutableMultiValueRef jobTitle=ABRecordCopyValue(person, kABPersonJobTitleProperty);
// ABMutableMultiValueRef kind=ABRecordCopyValue(person, kABPersonKindProperty);
// ABMutableMultiValueRef lastNamePhonetic=ABRecordCopyValue(person, kABPersonLastNamePhoneticProperty);
// ABMutableMultiValueRef lastName=ABRecordCopyValue(person, kABPersonLastNameProperty);
// ABMutableMultiValueRef middleNamePhonetic=ABRecordCopyValue(person, kABPersonMiddleNamePhoneticProperty);
// ABMutableMultiValueRef middleName=ABRecordCopyValue(person, kABPersonMiddleNameProperty);
// ABMutableMultiValueRef modificationDate=ABRecordCopyValue(person, kABPersonModificationDateProperty);
// ABMutableMultiValueRef nickname=ABRecordCopyValue(person, kABPersonNicknameProperty);
// ABMutableMultiValueRef note=ABRecordCopyValue(person, kABPersonNoteProperty);
// ABMutableMultiValueRef organization=ABRecordCopyValue(person, kABPersonOrganizationProperty);
// ABMutableMultiValueRef phone=ABRecordCopyValue(person, kABPersonPhoneProperty);
// ABMutableMultiValueRef prefix=ABRecordCopyValue(person, kABPersonPrefixProperty);
// ABMutableMultiValueRef relatedNames=ABRecordCopyValue(person, kABPersonRelatedNamesProperty);
// ABMutableMultiValueRef socialProfile=ABRecordCopyValue(person, kABPersonSocialProfileProperty);
// ABMutableMultiValueRef personSuffix=ABRecordCopyValue(person, kABPersonSuffixProperty);
// ABMutableMultiValueRef _URL=ABRecordCopyValue(person, kABPersonURLProperty);
NSMutableArray *phones = [[NSMutableArray alloc] init];
for (int i = 0; i < ABMultiValueGetCount(phoneMulti); i++) {
NSString *aPhone = (__bridge NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, i);
[phones addObject:aPhone];
}
NSLog(@"+qqqqqqqqqq++++%@",phones);
NSLog(@"****************");
NSString *mobileNo = [phones objectAtIndex:0];
// self.label.text = (NSString*)ABRecordCopyCompositeName(person);
NSLog(@"++++++++++++++++++++%@",mobileNo);
return YES;
}
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSString *aPhone = (__bridge NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, identifier);
ABMutableMultiValueRef firstName=ABRecordCopyValue(person, kABPersonFirstNameProperty);
ABMutableMultiValueRef lastName=ABRecordCopyValue(person, kABPersonLastNameProperty);
NSLog(@"+qqqqqqqqqq++++%@",aPhone);
NSLog(@"+FirstName=%@, lastName=%@", firstName, lastName);
[self dismissViewControllerAnimated:YES completion:^(void){}];
return NO;
}
#endif
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
//- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person
//{
//
// ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
// // ABMutableMultiValueRef address=ABRecordCopyValue(person, kABPersonAddressProperty);
// // ABMutableMultiValueRef birthday=ABRecordCopyValue(person, kABPersonBirthdayProperty);
// // ABMutableMultiValueRef creationDate=ABRecordCopyValue(person, kABPersonCreationDateProperty);
// // ABMutableMultiValueRef date=ABRecordCopyValue(person, kABPersonDateProperty);
// // ABMutableMultiValueRef department=ABRecordCopyValue(person, kABPersonDepartmentProperty);
// // ABMutableMultiValueRef email=ABRecordCopyValue(person, kABPersonEmailProperty);
// // ABMutableMultiValueRef firstNamePhonetic=ABRecordCopyValue(person, kABPersonFirstNamePhoneticProperty);
// // ABMutableMultiValueRef firstName=ABRecordCopyValue(person, kABPersonFirstNameProperty);
// // ABMutableMultiValueRef instantMessage=ABRecordCopyValue(person, kABPersonInstantMessageProperty);
// // ABMutableMultiValueRef jobTitle=ABRecordCopyValue(person, kABPersonJobTitleProperty);
// // ABMutableMultiValueRef kind=ABRecordCopyValue(person, kABPersonKindProperty);
// // ABMutableMultiValueRef lastNamePhonetic=ABRecordCopyValue(person, kABPersonLastNamePhoneticProperty);
// // ABMutableMultiValueRef lastName=ABRecordCopyValue(person, kABPersonLastNameProperty);
// // ABMutableMultiValueRef middleNamePhonetic=ABRecordCopyValue(person, kABPersonMiddleNamePhoneticProperty);
// // ABMutableMultiValueRef middleName=ABRecordCopyValue(person, kABPersonMiddleNameProperty);
// // ABMutableMultiValueRef modificationDate=ABRecordCopyValue(person, kABPersonModificationDateProperty);
// // ABMutableMultiValueRef nickname=ABRecordCopyValue(person, kABPersonNicknameProperty);
// // ABMutableMultiValueRef note=ABRecordCopyValue(person, kABPersonNoteProperty);
// // ABMutableMultiValueRef organization=ABRecordCopyValue(person, kABPersonOrganizationProperty);
// // ABMutableMultiValueRef phone=ABRecordCopyValue(person, kABPersonPhoneProperty);
// // ABMutableMultiValueRef prefix=ABRecordCopyValue(person, kABPersonPrefixProperty);
// // ABMutableMultiValueRef relatedNames=ABRecordCopyValue(person, kABPersonRelatedNamesProperty);
// // ABMutableMultiValueRef socialProfile=ABRecordCopyValue(person, kABPersonSocialProfileProperty);
// // ABMutableMultiValueRef personSuffix=ABRecordCopyValue(person, kABPersonSuffixProperty);
// // ABMutableMultiValueRef _URL=ABRecordCopyValue(person, kABPersonURLProperty);
//
//
// NSMutableArray *phones = [[NSMutableArray alloc] init];
//
// for (int i = 0; i < ABMultiValueGetCount(phoneMulti); i++) {
//
// NSString *aPhone = (__bridge NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, i);
// [phones addObject:aPhone];
// }
//
// NSLog(@"+qqqqqqqqqq++++%@",phones);
//
//
// NSLog(@"****************");
// NSString *mobileNo = [phones objectAtIndex:0];
//
// // self.label.text = (NSString*)ABRecordCopyCompositeName(person);
// NSLog(@"++++++++++++++++++++%@",mobileNo);
//
//
//}
// Called after a property has been selected by the user.
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
ABMutableMultiValueRef phoneMulti = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSString *aPhone = (__bridge NSString*)ABMultiValueCopyValueAtIndex(phoneMulti, identifier);
ABMutableMultiValueRef firstName=ABRecordCopyValue(person, kABPersonFirstNameProperty);
ABMutableMultiValueRef lastName=ABRecordCopyValue(person, kABPersonLastNameProperty);
NSLog(@"+qqqqqqqqqq++++%@",aPhone);
NSLog(@"+FirstName=%@, lastName=%@", firstName, lastName);
[self dismissViewControllerAnimated:YES completion:^(void){}];
}
#endif
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissViewControllerAnimated:YES completion:^(void){}];
}