Xero Xero - 28 days ago 6
iOS Question

Top navigation bar disabled

I'm trying to handle remote notification.
In my didReceive method in AppDelegate, I'm trying to open a view :

var storyboard = UIStoryboard(name: "Main", bundle: nil)
var destinationController = storyboard.instantiateViewController(withIdentifier: "InfoTraficViewController") as? InfoTraficViewController
destinationController?.infoTraficId = trafficInfoId
window?.rootViewController?.present(destinationController!, animated: true, completion: nil)


This is working, but the top navigation bar is not shown. So the user cannot go previous.

What can I do ? I tried :

self.navigationController?.setNavigationBarHidden(false, animated: animated)


But it's not working

EDIT :

It's working with :

var storyboard = UIStoryboard(name: "Main", bundle: nil)
var destinationController = storyboard.instantiateViewController(withIdentifier: "InfoTraficViewController") as? InfoTraficViewController
destinationController?.infoTraficId = trafficInfoId

var customUiNavController = storyboard.instantiateViewController(withIdentifier: "CustomUINavigationController") as? CustomUINavigationController
customUiNavController?.pushViewController(destinationController!, animated: true)

window?.rootViewController = customUiNavController


Thanks to Rajat

Answer

Change this

window?.rootViewController?.present(destinationController!, animated: true, completion: nil)

with this

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

As the issue is, you are presenting your UIViewController on the rootViewController of window, so this ViewController is on top of your UINavigationController.