联系人Picker无法正常工作

时间:2015-01-06 10:58:05

标签: ios iphone

当用户点按手机号码时,我希望在标签上显示联系号码。但我的代码第一部手机没有自动播放。我正在使用这个

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker  didSelectPerson:(ABRecordRef)person
{
    [self getPeopleContactProperties:person:0];
}

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    [self getPeopleContactProperties:person:identifier];
}

- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker;
{
    [self dismissViewControllerAnimated:YES completion:NULL];
}
- (void)getPeopleContactProperties :(ABRecordRef)person :(ABMultiValueIdentifier)identifier
{
     NSString *email;
       ABMultiValueRef emails = ABRecordCopyValue(person, kABPersonPhoneProperty);
    if (emails) {
        CFIndex index;
        if (identifier == 0) {
            index = 0;
        } else {
            index = ABMultiValueGetIndexForIdentifier(emails, identifier);
        }
        email = (__bridge NSString *) ABMultiValueCopyValueAtIndex(emails,index);
    }

    resultlabel.text =email;
}

1 个答案:

答案 0 :(得分:1)

if ([peoplePicker respondsToSelector:@selector(setPredicateForSelectionOfPerson:)])
{
     peoplePicker.predicateForSelectionOfPerson = [NSPredicate predicateWithFormat:@"%K.@count > 1", ABPersonPhoneNumbersProperty];
}