Reputation: 3636
My app use a splitViewcontroller. I removed the navigationBar of my DetailViewController. So I cannot use :
navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem()
navigationItem.leftItemsSupplementBackButton = true
But I need my own button to display my MasterViewController in a popover like the leftBarButtonItem done.
I tried :
@IBAction func showAll() {
rootViewController.splitViewController?.displayModeButtonItem().action
}
But it doesn't work.
EDIT :
I tried to add my own popover, with inside my masterViewController.
@IBAction func showAll(sender : UIButton!) {
let popover = UIPopoverController(contentViewController:masterViewController)
popover.presentPopoverFromRect(sender.frame, inView: self.view, permittedArrowDirections:UIPopoverArrowDirection(), animated: true)
}
But the app crashes :
Application tried to present modally an active controller <DetailViewController: 0x7f8393d96540>
I don't understand because I need to display the popover in the view of detailViewController. How can I do otherwise?
Upvotes: 0
Views: 563
Reputation: 3636
It works perfectly with @pbasdf solution :
@IBAction func showAll() {
self.splitViewController?.preferredDisplayMode = .PrimaryOverlay
self.splitViewController?.displayModeButtonItem().action
}
Upvotes: 1