Reputation: 2250
I've tried a few solutions I found here without much luck.
To keep it short, I want to do the following: Push an entirely new ViewController (in fullscreen) from a DetailView button, with the option to come back with the navigation back button.
Is there a way to easily do this or this?
Upvotes: 0
Views: 341
Reputation: 534
You should add your split controller into another navigation controller (consider it as a new initial controller if you're using storyboards). Then when you handle button's touch action push your different view controller like this:
let viewController = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DiffViewController")
self.splitViewController?.navigationController?.pushViewController(viewController, animated: true)
Nesting your split controller into navigation will present an extra navigation bar on the top of the screen. So to hide it subclass your split controller and add the following code:
final class YourSpllitViewController: UISplitViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: false)
}
}
And then make your Different controller do the following:
final class DiffViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: false)
}
}
That should be all you need.
Upvotes: 1