ios - 联系选择器不工作

标签 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;
}

最佳答案

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

关于ios - 联系选择器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27797196/

相关文章:

ios - 如何在 Objective-C 中格式化 Instagram 日期

iphone - 在 Objective C 编程中哪个是更可取的几何?

iphone - 页面控制宽度问题

iphone - 如何在ios中解压/提取7z压缩文件

ios - 应用程序因 startAnimating 方法而崩溃

ios 8 openUrl itms-services 不退出当前应用

ios - MKMapView 调用 didSelectAnnotationView

ios - 当 Sprite 到达路径末端时,如何从 SpriteKit 重复 Action 中获得回调?

iphone - 在 iPad 设备上测试应用程序

iphone - 仅在导航弹出后分组 UITableViewCell 上才会出现黑色角