사용자에게 연락처에서 전화 번호를 선택하고 선택한 번호를 UITextField에 표시 할 수있는 기능을 제공하려고합니다.ABMultiValueIdentifier는 항상 0입니다. (0) ABPeoplePicker
에서 shouldContinueAfterSelectingPerson
으로 반환되는 연락처에 어떤 번호를 선택했는지에 관계없이 항상 0 인 문제가 있습니다.
- (IBAction)btnChooseContactClicked:(id)sender {
[[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[picker setDisplayedProperties: [NSArray arrayWithObjects: [NSNumber numberWithInt: kABPersonPhoneProperty], nil]];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
}
- (void)peoplePickerNavigationControllerDidCancel:
(ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissModalViewControllerAnimated:YES];
}
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person {
return YES;
}
- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier //Always = 0
{
[self displayPerson:person property:property identifier:identifier];
[self dismissModalViewControllerAnimated:YES];
return NO;
}
- (void)displayPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSLog(name);
if (property == kABPersonPhoneProperty) {
ABMultiValueRef multiPhones = ABRecordCopyValue(person, kABPersonPhoneProperty);
for(CFIndex i = 0; i < ABMultiValueGetCount(multiPhones); i++) {
if(identifier == ABMultiValueGetIdentifierAtIndex (multiPhones, i)) {
CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(multiPhones, i);
CFRelease(multiPhones);
NSString *phoneNumber = (__bridge NSString *) phoneNumberRef;
CFRelease(phoneNumberRef);
self.txtTelNo.text = phoneNumber;
}
}
}
}
내가 다 잘 뭐하는 거지처럼 느낌이 나는 수많은 다른 사람을 따라하고 아무것도 작동하는 것 같다 없습니다 :
이 내 코드입니다. 무엇이 문제 일 수 있습니까?
안녕하세요 고맙지 만 현재 iOS 7.1에서 테스트 중이지만 확인해야하는 사항입니다. – PaperThick