I've been working on an app for a while now and it pushes a view controller from the AppDelegate. When it does the navigation bar that was previously on the view controller being pushed disappears. Right now it's a static nav bar (not part of a navigation controller), but it has been previously and still didn't work. What am I doing wrong? Is there some sort of workaround?
This is the code in the AppDelegate that I'm using to push it:
var storyboard = UIStoryboard(name: "Main", bundle: nil)
var PostView: AnyObject! = storyboard.instantiateViewControllerWithIdentifier("NewView")
var rootViewController = self.window!.rootViewController as! UINavigationController
rootViewController.pushViewController(PostView as! UIViewController, animated: true)
pushViewController
is the one I'm trying to push.
On the view controller that you are trying to push, on the viewDidLoad
method, try to force the navigation bar to not be hidden
self.navigationController?.setNavigationBarHidden(false, animated: false)
If this helps, check the view controller on the storyboard if you're not forcing the view controller to hides the navigation bar
Hope that helps :)
Try this:
var storyboard = UIStoryboard(name: "NewStoryBoard", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "NewView") as! UIViewController
self.navigationController?.pushViewController(vc, animated: true)
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