设置:我正在寻找洞察使用ABPersonViewContoller没有从地址簿中获取数据。我有一个JSON web服务,正在喂一个tableview,我有我的人对象存储在mutableArray作为字典。
Setup: I'm looking for insight into using a ABPersonViewContoller without getting data from the AddressBook. I have a JSON web service that is feeding a tableview and I have my person objects stored in a mutableArray as dictionaries.
我的问题:搜索和无法找到任何参考使用personViewController与您自己的对象。我可以初始化一个新的personView分配我的人对象和推控制器?
my Question: I've been searching and been unable to find any reference to using the personViewController with your own objects. Can I init a new personView assign it my person object and push the controller? or would I be better off rolling my own view to duplicate the apple one?
更新:由于Eric建议使用ABRecordRef作为我的对象,它的确是有意义的工作。这里是一个代码示例。
Update: As Eric suggested using a ABRecordRef as my object and it does infact work. here's a code example.
// get index and set person object int personIndex = [indexPath indexAtPosition: [indexPath length] - 1]; ABRecordRef person = ABPersonCreate(); ABRecordSetValue(person, kABPersonFirstNameProperty, [[personList objectAtIndex: personIndex] objectForKey: @"firstName"], nil); ABRecordSetValue(person, kABPersonLastNameProperty, [[personList objectAtIndex:personIndex] objectForKey:@"lastName"], nil); // initialize a personviewController ABPersonViewController *personViewController = [[ABPersonViewController alloc] init]; personViewController.personViewDelegate = self; personViewController.displayedPerson = person; personViewController.allowsEditing = NO; // push to view controller [[self navigationController] pushViewController:personViewController animated:YES]; [personViewController release];希望这有助于别人。
推荐答案ABPersonViewController 绑定到iOS设备的AddressBook(与整个地址簿UI框架),所以我相信它会更容易滚动自己的 UIViewController 得到你想要的。此外,文档注意到人员视图控制器必须与导航控制器一起使用才能正常工作。
The ABPersonViewController is tied to the iOS device's AddressBook (with the whole Address Book UI Framework), so I believe it would be easier to roll your own UIViewController to get what you want. Also, the docs note that "Person view controllers must be used with a navigation controller in order to function properly." So you are (possibly) limited there.
这说明了(我没有尝试过),但它确实出现了 displayedPerson 属性是 readwrite ,所以我想如果你的数据存储在你的数组作为 ABRecordRef 它可能工作。
That said (and I haven't tried it), but it does appear that the displayedPerson attribute is readwrite, so I suppose if your data was stored in your array as an ABRecordRef it might work.
更多推荐
如何在不连接到AddressBook的情况下使用ABPersonViewController
发布评论