A contacts picker component using Apple's Contacts framework.
This library was originally forked from JFContactsPicker
VDContactPicker is available on CocoaPods. Just add the following to your project Podfile:
pod 'VDContactPicker', '~> 1.0'
Just drag and drop the Source
folder into your project
- iOS9+
- Swift 4.1
- ARC
For manual installation you may need to add these frameworks in your Build Phases:
ContactsUI.framework
and Contacts.framework
.
VDContactPicker provides all common functionality and customization features:
[x] Single selection and multi-selection options. [x] Search Contacts [x] Configure the contact data to be shown. (Phone Number, Email, Birthday, or Organization) [x] Section indexes to easily navigate through the contacts. [x] Shows initials when image is not available. [x] Contact object to get the properties of the contacts
If you would like additional support for additional customization features, please Create a New Issue.
Initialize the picker by passing the delegate, multiselection option, and the secondary data type to be displayed (Phone Number, Email, Birthday, or Organization).
let contactPicker = VDContactPicker(delegate: self, multiSelection:false, subtitleCellType: .email)
let navigationController = UINavigationController(rootViewController: contactPicker)
self.present(navigationController, animated: true, completion: nil)
VDContactPicker provides you four delegate methods for responding to the picker's events.
func contactPicker(_ contactPicker: VDContactsPicker, didContactFetchFailed error : NSError)
func contactPicker(_ contactPicker: VDContactsPicker, didCancel error : NSError)
func contactPicker(_ contactPicker: VDContactsPicker, didSelectContact contact : VDContact)
func contactPicker(_ contactPicker: VDContactsPicker, didSelectMultipleContacts contacts : [VDContact])
The VDContact
object provides you the properties of a contact. This contains properties like displayName, initials, firstName, lastName, company, birthday, etc.
VDContactPicker is available under the MIT license. See the LICENSE file for more info.
Original Authors
@JettF
@AnthonyMDev
@ipraba
@Sorix