gpt4 book ai didi

iOS 在数组中获取选定联系人的电子邮件地址

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:56:50 26 4
gpt4 key购买 nike

我想要做的是向用户显示人员选择器,让他选择他想要的所有联系人,最后将所有这些联系人的电子邮件地址放在一个数组中。最好的办法是只向用户显示有电子邮件的联系人。

到目前为止,我唯一能做的就是向人员选择器显示以下代码:

ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];

然后我尝试使用此代码获取所选联系人的电子邮件:

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonEmailProperty);
[email addObject:(__bridge NSString*)ABMultiValueCopyValueAtIndex(multi, 0)];
[self dismissModalViewControllerAnimated:YES];

return YES;
}

但是选择联系人后选择器就消失了,所以我不知道如何继续。此外,当我选择一个联系人时,我会在控制台中看到:

"Unbalanced calls to begin/end appearance transitions for 
<ABMembersViewController: 0xa1618c0>."

如有任何帮助,我们将不胜感激。

最佳答案

我不确定您是否解决了您的问题,但如果其他人找到这篇文章,也许会对他们有所帮助。我为从 ABPeoplePickerNavigationController 收到电子邮件所做的是删除

[self dismissModalViewControllerAnimated:YES];

来自

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person;

然后我用它来获取电子邮件并关闭 Controller

- (BOOL)peoplePickerNavigationController(ABPeoplePickerNavigationController*)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
if (kABPersonEmailProperty == property)
{
ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonEmailProperty);
NSString *email = (__bridge NSString *)ABMultiValueCopyValueAtIndex(multi, 0);
NSLog(@"email: %@", email);
[self dismissModalViewControllerAnimated:YES];
return NO;
}
return YES;
}

它允许用户选择特定的电子邮件并在没有任何错误的情况下关闭 Controller 。

关于iOS 在数组中获取选定联系人的电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12003338/

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