This code collapses all of my UIViewController hierarchy
func openVCard(for cnContact: CNContact) {
let contactViewController = CNContactViewController(forUnknownContact: cnContact)
contactViewController.contactStore = CNContactStore()
contactViewController.delegate = self
let navigationController = UINavigationController(rootViewController: contactViewController)
let doneButton = UIBarButtonItem(title: "Close", style: .done, target: nil, action: nil)
let flexibleSpaceButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
contactViewController.setToolbarItems([flexibleSpaceButton, doneButton, flexibleSpaceButton], animated: false)
navigationController.isToolbarHidden = false
contactViewController.edgesForExtendedLayout = []
present(viewController: navigationController, animated: true, completion: nil)
}
but it seems ok for CNContactViewController(forNewContact
Is it an Apple bug?
You should push CNContactViewController instead of present. I suggest you to watch WWDC 2015 presentation about this issue.
https://developer.apple.com/videos/play/wwdc2015/223/
After 30:00 you can see demo about this issue.