1

在以下 UI 中,您可以从通讯录中选择人员。请注意,名称是可单击的,并在单击时启动地址簿。

在此处输入图像描述

在我的应用程序中,我可以从通讯录中选择联系人并提取全名,但是当我将其添加到 UITextField 时,它只显示为名称,不可点击如下:

在此处输入图像描述

Q. How can I make the name in my app clickable and it would take me to address book upon click.

我正在使用包装类与通讯录进行交互,这是我的代码。

- (BOOL)peoplePickerNavigationController:
(ABPeoplePickerNavigationController *)peoplePicker
      shouldContinueAfterSelectingPerson:(ABRecordRef)person
                                property:(ABPropertyID)property
                              identifier:(ABMultiValueIdentifier)identifier
{
    // Guaranteed to only be working with e-mail or phone here
    [self dismissModalViewControllerAnimated:YES];

    NSArray *array =
    [ABContact arrayForProperty:property inRecord:person];
    NSString *pickedValue = (NSString *)[array objectAtIndex:identifier];

    NSString *firstName = [[ABContact contactWithRecord:person] firstname];
    NSString *lastName = [[ABContact contactWithRecord:person] lastname];
    NSString *fullName = [[NSString alloc] initWithFormat:@"%@ %@",firstName, lastName];

    if (chooseEmail)
    {
        txtToEmailAddress.text = fullName;
    }
    if (choosePhone)
    {
        txtCallPhoneNum.text = fullName;

    }
    if (chooseText)
    {
        txtTextNumbers.text = fullName;

    }

    return NO;

}

如果可能,请提供带有答案的代码示例。我非常感谢。谢谢

4

1 回答 1

3

您可以查看一些开源想法,这可能会有所帮助。 https://github.com/beat843796/HEBubbleView

https://github.com/tristanhimmelman/THContactPicker

于 2013-01-23T15:46:03.463 回答