在以下用户界面中,您可以从通讯簿中选择人。请注意,名称是可单击的,并且在单击时启动地址簿。
在我的应用程序中,我可以从通讯录中选择联系人并提取全名,但是当我将其添加到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;
}
如果可能,请提供代码示例及其答案。我非常感谢。谢谢
最佳答案
您可以查看一些开源想法,这可能会有所帮助。
https://github.com/beat843796/HEBubbleView
https://github.com/tristanhimmelman/THContactPicker