Ishan Saksena Ishan Saksena - 3 months ago 24
iOS Question

Can't dismiss new contact CNContactViewController, no bar on top

I'm trying to let the user create a new contact. While I've got the screen to prompt the user to put in all his details there is no navigation bar at the top(Like there is in the default Apple Contacts app). There is no way to exit the scene. I'm using the ContactUI framework in swift 2.0 and Xcode 7.3. Here's the code:

// create a new contact
let createNewActionHandler = {(action: UIAlertAction) -> Void in
let newContact = CNMutableContact()

let contactPicker = CNContactViewController(forNewContact: newContact)
contactPicker.delegate = self
contactPicker.navigationController?.setToolbarHidden(false, animated: false)
self.presentViewController(contactPicker, animated: true, completion: nil)


Here's what I'm trying to get:
Apple Default

Here's what I have:
What I have

I'm launching the new contact view controller from an action sheet in a tab view controller. I tried embedding the tab in a Navigation view controller but to no effect. I even tried setting the setToolbarHidden property of the navController but it didn't help.

Thanks for any help. I saw the issue raised in other forums but they didn't help.


The view controllers must be embedded in UINavigationController and you should push or show view controller:

navigationController?.pushViewController(contactPicker, animated: true)

instead of presenting view controller