简体   繁体   English

如何在核心数据堆栈中的客户端上使用ABPeoplePickerNavigationController

[英]How to use ABPeoplePickerNavigationController on clients in core data stack

I have a core data stack which contains an entity called 'Client'. 我有一个核心数据栈,其中包含一个名为“客户端”的实体。 Each client has a 'addressBookID' property which refers to the uniqueID of the person record in the AddressBook. 每个客户端都有一个“ addressBookID”属性,该属性引用地址簿中个人记录的唯一ID。 I am currently using a fetchedResultsController to populate the tableViewController to display these clients. 我目前正在使用fetchedResultsController填充tableViewController来显示这些客户端。 However, the viewController is very basic. 但是,viewController是非常基本的。

Ideally, I want to use the ABPeoplePickerNavigationController UI so that my Clients are separated by sections of Last Initial and also have the drag bar on the right side which can quickly flick to the desired point in the alphabet. 理想情况下,我想使用ABPeoplePickerNavigationController UI,以便我的客户端由“最后一个初始”的各个部分分隔开,并且在右侧具有拖动栏,可以快速轻拂到字母表中的所需点。 The added search functionality would also be useful. 添加的搜索功能也将很有用。

Is is possible to use a ABPeoplePickerNavigationController but populate it with your own data (by using a delegate for example)? 是否可以使用ABPeoplePickerNavigationController,但用您自己的数据填充它(例如,通过使用委托)?

Alernatively, are these bits of functionality easily added to a fetchedResultsController style table? 替代地,这些功能是否可以轻松地添加到fetchedResultsController样式表中? The only other issue I have is being able to fetch results from the Core Data stack but sort them by their names as stored in the ABAddressBook. 我唯一遇到的另一个问题是能够从Core Data堆栈中获取结果,但按存储在ABAddressBook中的名称对它们进行排序。 I am not sure a sortDescriptor can sort by reference to field stored outside the stack. 我不确定sortDescriptor是否可以根据对堆栈外部存储的字段的引用进行排序。

Appreciate any advice/comments? 欣赏任何建议/意见吗?

You need to create an ABAddressBookRef and populate it with the contacts that you want to appear in the navigation controller. 您需要创建一个ABAddressBookRef并使用要显示在导航控制器中的联系人来填充它。 Then create the ABPeoplePickerNavigationController and assign your ABAddressBookRef to the addressBook property. 然后创建ABPeoplePickerNavigationController并将ABAddressBookRef分配给addressBook属性。

ABPeoplePickerNavigationController documentation ABPeoplePickerNavigationController文档

Optional. The address book from which to obtain the list of contacts.

@property(nonatomic, readwrite) ABAddressBookRef addressBook

To create an ABAddressBookRef, start with ABAddressBookCreate() and ABAddressBookAddRecord(). 要创建ABAddressBookRef,请从ABAddressBookCreate()和ABAddressBookAddRecord()开始。 These functions are documented in Apple's ABAddressBook Reference for iOS . 这些功能记录在Apple的iOS版ABAddressBook参考中

If you want the changes to the ABAddressBookRef to not be saved (in other words, you want to set it up with temporary contacts), simply don't call ABAddressBookSave(). 如果您不想保存对ABAddressBookRef的更改(换句话说,您想使用临时联系人进行设置),只需不要调用ABAddressBookSave()。 The documentation states 文档说明

Changes made to the returned address book are reflected in the Address Book database only after saving the address book with ABAddressBookSave. 仅使用ABAddressBookSave保存通讯簿后,对返回的通讯簿所做的更改才会反映在通讯簿数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何正确使用ABPersonViewController与ABPeoplePickerNavigationController查看联系信息? - How to correctly use ABPersonViewController with ABPeoplePickerNavigationController to view Contact information? 如何将leftBarButtonItem添加到ABPeoplePickerNavigationController? - How to add a leftBarButtonItem to ABPeoplePickerNavigationController? 核心数据迁移:如何删除核心数据堆栈? - Core Data Migration: How to delete the Core Data stack? ABPeoplePickerNavigationController - ABPeoplePickerNavigationController 在使用ABPeoplePickerNavigationController之后,展开segue崩溃 - Unwind segue crashes after ABPeoplePickerNavigationController use 从ABPeoplePickerNavigationController获取人员时缺少数据 - Lack of data when getting person from ABPeoplePickerNavigationController ABPeoplePickerNavigationController在单个cel中显示所有联系人数据 - ABPeoplePickerNavigationController display all contact data in a single cel 如何设置ABPeoplePickerNavigationController的提示? - How do I set an ABPeoplePickerNavigationController's prompt? 如何在Swift中使用ABPeoplePickerNavigationController选择多个联系人 - how to select multiple contacts with ABPeoplePickerNavigationController in Swift 如何绕过ABPeoplePickerNavigationController缺少“添加”按钮? - how to get around lack of 'add' button in ABPeoplePickerNavigationController?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM