sriram hegde
sriram hegde

Reputation: 2471

CNContactPickerViewController() in xcode7 swift2

How do I use CNContactPickerViewController() in xcode7 swift , should I import ContactsUI framework ,Im not sure , Basically I want to show the ContactPickerViewController when a button is pressed .

Note : If you guys know know the equivalent of the above in AddressBookUI Framework in swift or objective-c Please be helpful in sharing it I will modify it to make that work in ContactsUI Framework and i will post that so that it will useful for others in future

Upvotes: 1

Views: 3122

Answers (1)

AkhilS
AkhilS

Reputation: 93

Follow these steps:

import ContactsUI

In your code initialize :

let contactPicker = CNContactPickerViewController()
contactPicker.displayedPropertyKeys =
    [CNContactEmailAddressesKey, CNContactPhoneNumbersKey]
self.presentViewController(contactPicker, animated: true, completion: nil)

The code should be presented and not pushed into navigation controller else you will see a black screen on the view with a delayed animation.

Upvotes: 8

Related Questions