I am using the Contacts and ContactsUI in IOS9 and swift and happy with it.
In my program, I want the user to add a contact by using only these keys:
GivenName
, FamilyName
, PhoneNumbers
, EmailAdresses
.
However when I set these values in displayedPropertyKeys it didn't work.
Then I realized that it works only if initialized the CNCOntactViewController
by forContact and not forNewContact
is there is a way to overcome this?
The Code that I used is as follow:
let contact = CNMutableContact()
let ContactController = CNContactViewController(forNewContact: contact)
ContactController.delegate = self
ContactController.displayedPropertyKeys = [CNContactGivenNameKey,CNContactFamilyNameKey,CNContactPhoneNumbersKey,CNContactEmailAddressesKey] //this code is not working.
ContactController.hidesBottomBarWhenPushed = true
self.navigationController?.pushViewController(ContactController, animated: true)