作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我选择具有多个电话号码的联系人并选择他们的电话号码之一时,此方法工作正常,收件人地址设置为选定的电话号码。但是,当我从具有多个电子邮件地址的联系人中选择电子邮件地址时,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/
- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker s
我正在尝试获取选定的手机号码 ABMultiValueRef phones = ABRecordCopyValue(person, property); CFStringRef phoneNumber
我正在运行以下代码,它利用 Apple 的地址簿 UI。取消方法有效,但我的 shouldContinueAfterSelecting 无效。当我单击通讯簿 View Controller 中的联系人
我是一名优秀的程序员,十分优秀!