ABPersonViewController不显示除了名称的属性
来源:互联网 发布:linux crontab 权限 编辑:程序博客网 时间:2024/05/16 10:41
转自:http://stackoverflow.com/questions/5013349/why-doesn-t-abpersonviewcontroller-show-any-properties-besides-the-name
For some reason, ABPersonViewController
is unwilling to display any properties aside from the name, no matter what properties are set for it to display.
I’m unable to use the AddressBookUI
controllers to let a user select a contact to display, since my UI has custom requirements, otherwise I’d go that route (as Apple does in their sample project.)
Here’s the code that doesn’t work — am I missing something?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ // ABContact is of my own creation ABContact *contact = [self contactAtIndexPath: indexPath]; ABPersonViewController *viewController = [[ABPersonViewController alloc] init]; // This returns a valid ABRecordRef, as indicated by the fact that the // controller does display the name of this contact when it is loaded viewController.displayedPerson = contact.record; // Copied directly from Apple’s QuickContacts sample project NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], [NSNumber numberWithInt:kABPersonEmailProperty], [NSNumber numberWithInt:kABPersonBirthdayProperty], nil]; viewController.displayedProperties = displayedItems; [self.navigationController pushViewController: viewController animated: YES]; [viewController release];}
4 Answers
The value of these constants is undefined until one of the following functions has been called: ABAddressBookCreate, ABPersonCreate, ABGroupCreate.
The above is come from apple document. I think those property constants are not valid for above reason.
ABContact is from Erica Sadun's ObjC wrapper (ABContactsHelper), right?
I'm using it too and found that for some reason, Apple's ABPersonViewController somehow treats supplied ABRecordRef as contact.record differently than if you directly use C functions. Thus this:
ABContact *person = ...;ABPersonViewController *personVC = ...;personVC.displayedPerson = person.record;
will load almost nothing into the controller. Sometimes first/last name, sometimes not even that. However, if you do this:
ABContact *person = ...;ABPersonViewController *personVC = ...;ABAddressBookRef addressBook = ABAddressBookCreate();personVC.displayedPerson = ABAddressBookGetPersonWithRecordID(addressBook, person.recordID);
then it will load everything.
Previous answer says that ABAddressBookCreate is required for the constants to have a value, but this is already done in [ABContactsHelper addressBook] call (first thing I call in my code). This it's really puzzling where it gets lost. But the previous does work, consistently.
- ABPersonViewController不显示除了名称的属性
- TOCControl中图层名称不显示的问题
- TOCControl中图层名称不显示的问题
- 显示js对象的所有属性名称和属性值
- [ecshop 资料]商品显示 选择属性名称然后标题也加上属性的名称
- 插入某电信卡运营商名称不显示的问题
- iframe不显示边框的四个属性
- MFC listcontrol不显示设置的属性
- 系统属性的名称
- 显示权限的名称
- 亿图参与者名称不显示
- DataBinder.Eval:“System.Data.DataRowView”不包含名称为 cid 的属性。
- JS的function名称最好不与表单里标签属性名同名
- Freemarker不显示对象的属性值的原因
- 定义属性名称的技巧
- CALayer 属性不显示错误
- 关于标记中不显示title属性的解决办法
- input value 属性遇到引号不显示的解决方法
- CUDA开发环境配置大全
- 含有重复元素的全排列
- 拓扑排序 Codecorces510C Fox And Names
- 使用log4j的一个工程改名后并存于一个tomcat服务器一个无法启动
- Android中Intent的几种使用方法
- ABPersonViewController不显示除了名称的属性
- UVa 10596 - Morning Walk
- hdoj The mook jong 5366 (简单规律 打表)
- 数论之 素因子分解,素数筛选法,欧拉函数和扩展欧几里得算法 (整理)
- poj2007 Scrambled Polygon (叉积极角排序)
- BZOJ 1356 [Baltic2009]Rectangle 数学
- 类型参数约束
- 优秀程序员的45个习惯
- Java enum的集合用法