To be able to select a contact in iOS 8, you need to use this:
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person { ....
Of course, first you need to match ABPeoplePickerNavigationControllerDelegate .
Example:
-(void)openPeoplePicker { ABPeoplePickerNavigationController *personPicker = [ABPeoplePickerNavigationController new]; personPicker.peoplePickerDelegate = self; [self presentViewController:personPicker animated:YES completion:nil]; } - (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person { NSString *firstName; NSString *middleName; NSString *lastName; NSDate *retrievedDate; UIImage *retrievedImage; // get the first name firstName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); //get the middle name middleName = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonMiddleNameProperty); // get the last name lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); // get the birthday retrievedDate = (__bridge_transfer NSDate*)ABRecordCopyValue(person, kABPersonBirthdayProperty); // get personPicture if (person != nil && ABPersonHasImageData(person)) { retrievedImage = [UIImage imageWithData:(__bridge_transfer NSData*)ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail)]; } else { retrievedImage = nil; } //set the name if (firstName != NULL && middleName != NULL && lastName != NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@ %@ %@",firstName,middleName,lastName]; } if (firstName != NULL && middleName != NULL & lastName == NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@ %@",firstName, middleName]; } if (firstName != NULL && middleName == NULL && lastName != NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@ %@",firstName,lastName]; } if (firstName != NULL && middleName == NULL && lastName == NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@",firstName]; } if (firstName == NULL && middleName != NULL && lastName != NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@ %@",middleName, lastName]; } if (firstName == NULL && middleName != NULL && lastName == NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@",middleName]; } if (firstName == NULL && middleName == NULL && lastName != NULL) { retrievedName = [[NSString alloc] initWithFormat:@"%@", lastName]; } [self dismissViewControllerAnimated:NO completion:^(){}]; }
source share