사람 선택 도구가있는 ios 7이 있고 ios 8과의 호환성을 추가하려고합니다. 두 방법을 모두 하나에 추가했지만 예상되는 식별자가 잘못되었습니다. 또는 '('는 NSString * 연락처 이름 앞에 여는 괄호에. 어떤 제안은 좋은 것입니다! 관심을 가질만한 사람들을위한ios 7 및 ios 8을 사용하는 사람 선택기
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
[self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];
NSString *contactName = CFBridgingRelease(ABRecordCopyCompositeName(person));
self.nameField.text = [NSString stringWithFormat:@"%@", contactName ? contactName : @"No Name"];
ABMultiValueRef phoneRecord = ABRecordCopyValue(person, kABPersonPhoneProperty);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phoneRecord, 0);
self.phoneField.text = (__bridge_transfer NSString *)phoneNumber;
CFRelease(phoneRecord);
ABMultiValueRef email = ABRecordCopyValue(person, kABPersonEmailProperty);
CFStringRef emailField = ABMultiValueCopyValueAtIndex(email, 0);
self.emailField.text = (__bridge_transfer NSString *)emailField;
CFRelease(email);
CFDataRef photo = ABPersonCopyImageData(person);
UIImage* image = [UIImage imageWithData:(__bridge NSData*)photo];
if(photo)
CFRelease(photo);
if(image)
self.myImageView.image = image;
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}
-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
[self dismissViewControllerAnimated:YES completion:nil];
return NO; }
내가 할 것은 이전 위임 메서드와 새 위임 메서드를 모두 구현하는 것입니다. 오른쪽 하나가 자동으로 호출됩니다. – matt
감사합니다! 그게 내가 생각하는 더 나은 접근 방법이다. –
코드 스 니펫을 업데이트했는데이 문제를 해결하는 방법에 대한 아이디어가 하나있다. –