Reputation: 833
I am trying to navigate the second controller from the storyboard but the navigation bar is not showing on a controller. Actually I want to show controller from app delegates.
here is my code:
let storyboard = UIStoryboard(name: AppStoryboards.MAIN, bundle: Bundle.main)
guard let controller = storyboard.instantiateViewController(withIdentifier: ViewControllerIdentifiers.THREAD_DETAIL_CONTROLLER) as? ThreadDetailController else {
return
}
controller.threadIdReceivedFromFeed = threadId as? String ?? String()
self.window?.rootViewController = controller
here is actual result:
Upvotes: 0
Views: 422
Reputation: 24341
You need to use add the controller
as the rootViewController
of the UINavigationController
and then set that navigationController
as window's
rootViewController
, i.e.
let storyboard = UIStoryboard(name: AppStoryboards.MAIN, bundle: nil)
if let controller = storyboard.instantiateViewController(withIdentifier: ViewControllerIdentifiers.THREAD_DETAIL_CONTROLLER) as? ThreadDetailController {
controller.threadIdReceivedFromFeed = (threadId as? String) ?? ""
let navigationController = UINavigationController(rootViewController: controller) //here...
self.window?.rootViewController = navigationController
}
Upvotes: 1