我在实现 ABPeoplePickerNavigationControllerDelegate 时遇到了这个奇怪的问题。因此有时标识符在委托(delegate)方法中获取的值不正确
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier;
例如,当我选择联系人的第一个号码时,标识符应该为 0。但有时它是 1(即使该联系人只有 1 个号码)!
很容易验证,
...
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
int count = ABMultiValueGetCount(phoneProperty);
NSLog(@"How many numbers do I have %d and which number do I choose %d",count,identifier);
有时会打印出这个
How many numbers do I have 1 and which number do I choose 1
有人也遇到同样的问题吗?
更新:有时标识符甚至比计数还要大。怎么会!!
How many numbers do I have 2 and which number do I choose 3
最佳答案
刚刚弄清楚原因并为自己感到尴尬。
所以 ABMultiValueIdentifier 与索引不同,在获得标识符后,我需要使用 ABMultiValueGetIndexForIdentifier 来获取索引。然后使用该索引调用 ABMultiValueCopyValueAtIndex。
顺便说一句,AdressBook Crash, only with some contacts! 也有同样的问题
关于ios - ABPeoplePickerNavigationControllerDelegate 中的 ABMultiValueIdentifier 未正确设置,这是 iOS 错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10309164/