gpt4 book ai didi

iphone - ABPeoplePickerNavigationControllerDelegate:shouldContinueAfterSelectingPerson提供带有电子邮件地址的错误ABMultiValue ID

转载 作者:行者123 更新时间:2023-12-01 18:19:01 24 4
gpt4 key购买 nike

当我选择具有多个电话号码的联系人并选择他们的电话号码之一时,此方法工作正常,收件人地址设置为选定的电话号码。但是,当我从具有多个电子邮件地址的联系人中选择电子邮件地址时,ABMultiValueIdentifier为零,并且它将转换为零索引,该索引始终是联系人中的最后一封电子邮件,无论我选择了哪个。

我一定在做令人尴尬的错误且容易发现的事情,所以请通过暴露我的愚蠢使自己看起来很棒。

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{
@try {
[eta addRecipient: person : property: identifier];
}
@catch (NSException *exception) {
errExcLog(exception);
}
return NO;
}

- (void) addRecipient : (ABRecordRef) person : (ABPropertyID) property : (ABMultiValueIdentifier)identifier {
ABMultiValueRef mvPropertyRef = ABRecordCopyValue(person, property);
int propertyIndex = ABMultiValueGetIndexForIdentifier( mvPropertyRef, identifier);
NSString *recipientAddress = (__bridge NSString *)(ABMultiValueCopyValueAtIndex( mvPropertyRef, propertyIndex));
}

最佳答案

这两种方法可能有助于您获取所选人员的电子邮件ID

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
shouldContinueAfterSelectingPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifier
{
ABPersonViewController *controller = [[ABPersonViewController alloc] init];
controller.displayedPerson = person;
controller.displayedProperties = [NSArray arrayWithObject:[NSNumber numberWithInt:kABPersonEmailProperty]];
controller.personViewDelegate = self;
[peoplePicker pushViewController:controller animated:YES];
[controller release];
return NO;
}

-(BOOL)personViewController:(ABPersonViewController *)personViewController
shouldPerformDefaultActionForPerson:(ABRecordRef)person
property:(ABPropertyID)property
identifier:(ABMultiValueIdentifier)identifierForValue
{
ABMutableMultiValueRef multiEmail = ABRecordCopyValue(person, property);

NSString *emailAddress = (NSString *) ABMultiValueCopyValueAtIndex(multiEmail, identifierForValue);

NSLog(@"strEmail %@",emailAddress);

ABPeoplePickerNavigationController *peoplePicker = (ABPeoplePickerNavigationController *)personViewController.navigationController;
[peoplePicker dismissViewControllerAnimated:YES completion:nil];
return NO;
}

关于iphone - ABPeoplePickerNavigationControllerDelegate:shouldContinueAfterSelectingPerson提供带有电子邮件地址的错误ABMultiValue ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18776005/

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