在以下 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;
}
如果可能,请提供带有答案的代码示例。我非常感谢。谢谢