Faisal Syed Faisal Syed - 6 months ago 42
Swift Question

Navigation Bar not showing when presenting View?

In another file I'm creating an instance of my view controller from another storyboard and presenting it like so:

let viewController:UIViewController = UIStoryboard(name: "UserProfile", bundle: nil).instantiateViewControllerWithIdentifier("profileID") as! ProfileViewController
self.presentViewController(viewController, animated: true, completion: nil)

In my storyboard I have the correct storyboard ID and embedded my view controller in a UINavigationController. I also set the initial view controller to the UINavigationController.

Why isn't it showing up?


create object of view controller then add navigation controller to it, and then present it :

let VC1 = self.storyboard!.instantiateViewControllerWithIdentifier("MyViewController") as! ViewController
let navController = UINavigationController(rootViewController: VC1) // Creating a navigation controller with VC1 at the root of the navigation stack.
self.presentViewController(navController, animated:true, completion: nil)