1

我与链接的联系人有联系。因此,当我向 ABPersonViewController 显示此联系人时,会显示来自链接联系人的原始电子邮件和电子邮件。 在此处输入图像描述

当我选择链接的电子邮件(John-appleseed@mac.com)然后委托方法调用:

- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
    //get selected phone number
    ABMultiValueRef multi = ABRecordCopyValue(person, property);
    CFIndex index = ABMultiValueGetIndexForIdentifier(multi, identifier);
    NSString *selectedContactData = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(multi, index);

    return NO;
}

但是在 selectedContactData 中,我收到的不是选定的电子邮件,而是第一封。我只有组合联系人才有这个问题。

是否有正确的方法从与已连接联系人的联系人中选择电子邮件?

4

1 回答 1

1

我可以想象您描述的行为的唯一方法是您可能在某些属性或 ivar 中引用您ABRecordRef第一次填充. 显然,在这段代码片段中,您正确地使用了传递给此委托方法的属性,但也许您在与我们分享时简化了代码片段?当我使用您的代码片段时,它适用于链接联系人的属性。displayedPersonABPersonViewControllerpersonshouldShowLinkedPeople

如果您确定使用错误的ABRecordRef变量没有问题,那么我能想象的唯一另一种可能性是,我在使用模拟器上提供的默认联系人时遇到了奇怪的行为。我可能会建议在具有真实链接联系人的实际设备上尝试此操作。

于 2015-03-24T18:34:42.383 回答