Ios ABMultiValueIdentifier始终为0(零)ABPeoplePicker

Ios ABMultiValueIdentifier始终为0(零)ABPeoplePicker,ios,objective-c,iphone,abpeoplepickerview,Ios,Objective C,Iphone,Abpeoplepickerview,我试图让用户能够从联系人中选择一个电话号码,然后在UITextField中显示所选号码 问题在于,无论您在联系人上选择了哪个号码,从返回的ab多值标识符在选择Person后都应继续为0 这是我的代码: - (IBAction)btnChooseContactClicked:(id)sender { [[UINavigationBar appearance] setBackgroundColor:[UIColor whiteColor]]; [[UINavigationBar ap

我试图让用户能够从联系人中选择一个电话号码,然后在UITextField中显示所选号码

问题在于,无论您在联系人上选择了哪个号码,从
返回的
ab多值标识符
在选择Person
后都应继续为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;
            }
        }
    }

}
-(iAction)btnChooseContactClicked:(id)发件人{
[[UINavigationBar外观]setBackgroundColor:[UIColor whiteColor]];
[[UINavigationBar外观]setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[picker setDisplayedProperties:[NSArray arrayWithObjects:[NSNumber numberWithInt:KabbersonPhoneProperty],nil]];
picker.peoplePickerDelegate=self;
[自我呈现ModalviewController:picker动画:是];
}
-(无效)peoplePickerNavigationControllerDidCancel:
(ABPeoplePickerNavigationController*)peoplePicker
{
[自我解散Modalviewcontrolleranimated:是];
}
-(BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController*)peoplePicker
选择人员后应继续:(ABRecordRef)人员{
返回YES;
}
-(BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController*)peoplePicker
选择人员后应继续:(ABRecordRef)人员
属性:(ABPropertyID)属性
标识符:(ABMultiValueIdentifier)标识符//始终=0
{
[自显示人员:人员属性:属性标识符:标识符];
[自我解散Modalviewcontrolleranimated:是];
返回否;
}
-(void)displayPerson:(ABRecordRef)person属性:(ABPropertyID)属性标识符:(ABMultiValueIdentifier)标识符
{
NSString*名称=(uuu桥u传输NSString*)ABRECORDCYVALUE(person,KabbersonfirstNameProperty);
NSLog(名称);
if(property==kabbersonphoneproperty){
ABMultiValueRef multiPhones=ABRecordCopyValue(person,kABPersonPhoneProperty);
对于(CFIndex i=0;i
我觉得我做的每件事都是对的,我跟随了无数其他人,但似乎什么都不管用。
可能是什么问题

在iOS8中,可以选择使用ABPeoplePickerViewController,而无需首先进行身份验证。如果您正在这样做,那么您只允许访问用户选择的值的数据-所有其他id都设置为无效

在打开ABPeoplePickerViewController之前,首先尝试进行身份验证,并检查是否接收到正确的数据


我在尝试检索被挑选的人的缩略图图像时也遇到了同样的问题-未经验证,该图像始终为空。

结果表明,问题出在我手机中的测试用户身上。
该用户有2个电话号码,均设置为“移动”类型。如果是这样的话,采摘者似乎看不到它们之间的区别。有人能证实这一点吗?还是我在胡说八道

您好,谢谢,但我目前正在iOS 7.1上测试,但这也是我必须检查的