我正在实现
- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
在我的自定义类中进行委托(delegate),该类是ABPersonViewController
的子类。委托(delegate)方法正在捕获 ABPersonViewController
子类内的单击事件。但我怎么知道到底哪个字段被点击了呢?例如。如果我单击家庭地址字段,我将如何在委托(delegate)方法中处理这种情况。
最佳答案
- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier{
if(property == kABPersonAddressProperty){
ABMutableMultiValueRef multi = ABRecordCopyValue(person, property);
CFStringRef address = ABMultiValueCopyValueAtIndex(multi, identifier);
NSLog(@"Address %@", (NSString *)address);
// Do your tasks here
CFRelease(address);
}
return YES;
}
就像kABPersonAddressProperty
一样,您可以检查所有其他属性,例如电话号码、电子邮件、网址等。
关于iphone - 处理 ABPersonViewController 内的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10394637/