gpt4 book ai didi

iphone - peoplePickerNavigationController 捕获实际联系人姓名的点击

转载 作者:行者123 更新时间:2023-11-29 13:39:59 25 4
gpt4 key购买 nike

我正在尝试捕捉联系人姓名的点击,并从那里获取联系信息。而不是点击联系人的信息并从那里点击一个字段。

我能够获取所有需要的数据,但只有在点击联系人后才能获取。这是我当前的代码:

-(IBAction)buttonPressed:(id)sender
{
ABPeoplePickerNavigationController *picker =[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
}

-(BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
[self displayPerson:person];

[self dismissModalViewControllerAnimated:YES];

return YES;
}

-(void)displayPerson:(ABRecordRef)person
{
NSString *name = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);

NSLog(@"Name: %@", name);

NSString *phone = nil;

ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

if (ABMultiValueGetCount(phoneNumbers) > 0) {

phone = (__bridge_transfer NSString *)

ABMultiValueCopyValueAtIndex(phoneNumbers, 0);

} else {

phone = @"[None]";

}

NSLog(@"Phone: %@", phone);
}

- (void)peoplePickerNavigationControllerDidCancel: (ABPeoplePickerNavigationController *)peoplePicker
{
[self dismissModalViewControllerAnimated:YES];
}

最佳答案

只需在 shouldContinueAfterSelectingPerson 中返回 NO

根据docs :

Return Value:
YES to display the contact and dismiss the picker.
NO to do nothing.

因此,通过返回 NO,您可以跳过显示步骤。无论如何,您自己都在解雇选择器。

关于iphone - peoplePickerNavigationController 捕获实际联系人姓名的点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9449222/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com