I have 2 storyboards. in Main.storyboard I have a view controller with a button. When the button is clicked I load the second storyboard Second.storyboard. This is the code I use to load the Second.storyboard
DispatchQueue.main.async {
let storyBoard : UIStoryboard = UIStoryboard(name: "Second", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "Tools") as UIViewController
self.present(nextViewController, animated:true, completion:nil)
}
In Second.storyboard I have a navigation controller and 2 view controller A and B.
The problem is that when running, I don’t see the back button in B to go back to A.
Things that I have tried: I have created another project. I embedded a navigation controller and 2 view controllers A and B in main.storyboard. This works fine. The back button is shown. This tell me that I am missing something when I load the second storyboard
I have tried adding this
// Do any additional setup after loading the view.
self.title = "Title"
let navigationBar = navigationController!.navigationBar
navigationBar.tintColor = UIColor.blue
let leftButton = UIBarButtonItem(title: "Left Button", style: UIBarButtonItemStyle.plain, target: self, action: nil)
let rightButton = UIBarButtonItem(title: "Right Button", style: UIBarButtonItemStyle.plain, target: self, action: nil)
navigationItem.leftBarButtonItem = leftButton
navigationItem.rightBarButtonItem = rightButton
I see some samples that load storyboards without this line DispatchQueue.main.async {}
. However; If I don use it I get an error and the program crush.
How do I add the Navigation Controller? I select the first View Controller, Editor, Embed in, Navigation Controller.
I am trying to display a navigation controller on a second storyboard and it is not showing the back button.
Needles to say that This is the second App I am trying to do and any help would be very much appreciated.