IOS9 ContactsUI Specific Condition

102 Views Asked by At

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)
1

There are 1 best solutions below

0
On BEST ANSWER

If you are using the pre build ContactUI do add the user, than you can't select what fields to show, It will follow the Apple's Contact App view.

What you can do is make it programatically, develop your own UI to add a contact.

follow this tutorial for more info. See section 4.1: Tutorial