I am setting up Push Notifications that I will send to the device with some data, and I want to load a certain view on the navigation controller stack. However, I want to keep the navigation stack intact, i.e. the destination view controller should still have a navigation bar with back button to go backwards to previous view controller, etc.
Flow: Navigation Controller -> Root View Controller -> Destination Controller.
How can I go about displaying a specific, non-root, view controller in a UINavigationController stack without losing hierarchy and functionality?
Right now I am doing this and it shows the View Controller properly, but no navigation bar:
let idPushNotification = userInfo["idPushNotification"] as String
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationViewController = storyboard.instantiateViewControllerWithIdentifier("DestinationViewController") as DestinationViewController
destinationViewController.idPushNotification = idPushNotification.toInt()!
let navigationController = self.window?.destinationViewController;
navigationController?.presentViewController(destinationViewController, animated: false, completion: nil)
You are presenting the view controller so it will not show any navigationBar.You need pushViewController on navigation stack
let navigationController:UINavigationController = self.window?.destinationViewController as UINavigationController;
navigationController?.pushViewController(destinationViewController, animated: false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With