Search code examples
iosswiftuinavigationcontrollercncontact

Why top Navigation Bar disappear when do some action on the view using Swift?


I have ViewController which has one button to navigate to CNContactViewController every thing works good I can go back and press the button again and so on .But my problem when I do one action on the CNContactViewController which is Share Contact the top navigation bar will disappear and for sure I'll stuck in this view .. this is the code:

    @IBAction func dothis(sender: AnyObject) {

    let contact = CNMutableContact()
    contact.givenName = "first Name"
    contact.familyName = "Last Name"
    contact.phoneNumbers = [CNLabeledValue(
        label:"Mobile",
        value:CNPhoneNumber(stringValue:"123456789")),
        CNLabeledValue(
            label:"Work Phone",
            value:CNPhoneNumber(stringValue:"1234"))]

    let workEmail = CNLabeledValue(label:"Work Email", value:"ex@whatever.com")
    contact.emailAddresses = [workEmail]

    let controller = CNContactViewController (forContact: contact)
    controller.contactStore = self.store
    controller.allowsEditing = false

    controller.displayedPropertyKeys =
        [CNContactPhoneNumbersKey,CNContactEmailAddressesKey, CNContactPostalAddressesKey]

    self.navigationController?
        .pushViewController(controller, animated: true)

}

Do I need to implement something more for share contact and other actions on the CNContactViewController ?

Notes:

1- All actions on contact card work good like Call or Send Message except Share Contact causing the problem.

2- When I compare the actions on my VC with the Contacts app I notice that the pop up options view of Share Contact comes over the navigation bar but in my app the options view come behind the navigation bar .

See Contacts app on the left and my app on the right :

Contacts App hereMy App

My Project file : Here it's small project


Solution

  • I did update Xcode to version 8.0 with Swift 3 and the problem solved without changing the code.