如何在不连接到AddressBook的情况下使用ABPersonViewController

编程入门 行业动态 更新时间:2024-10-25 16:18:59
本文介绍了如何在不连接到AddressBook的情况下使用ABPersonViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

设置:我正在寻找洞察使用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

本文发布于:2023-11-15 04:22:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591113.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   情况下   如何在   AddressBook   ABPersonViewController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!