Amr Mohamed
Amr Mohamed

Reputation: 2380

How to show a NavigationBar on detailViewController of SplitViewController iOS 8

i am using the new iOS 8 SplitViewController i am setting only one detailViewController from storyboard and then i use showDetailViewController() to show a new viewController

self.splitViewController?.showDetailViewController(TableViewController(), sender: nil)

but the NavigationBar is always hidden is there a way to put a NavigationBar on the detailViewController

and yeah btw i tried to unhide the NavigationBar but not working

self.navigationController?.setNavigationBarHidden(false, animated: true)

Upvotes: 4

Views: 4618

Answers (2)

Amr Mohamed
Amr Mohamed

Reputation: 2380

simply we can put a UINavigationController before TableViewController like this and show the navigationController

var nav = UINavigationController(rootViewController:TableViewController())
self.splitViewController?.showDetailViewController(nav, sender: nil)

Upvotes: 8

Sachin Palewar
Sachin Palewar

Reputation: 478

I write this in prepareForSegue method of master. You will need to replace DetailViewController with TableViewController in your code. May be you can also write similar code in TableViewController's viewDidLoad as well, but I am not sure. For my code sample with this code, check this Blog Post

let controller = (segue.destinationViewController as UINavigationController).topViewController as DetailViewController

            controller.navigationItem.leftBarButtonItem = self.splitViewController?.displayModeButtonItem()
            controller.navigationItem.leftItemsSupplementBackButton = true

Upvotes: 0

Related Questions