lascoff
lascoff

Reputation: 1331

Display master view programmatically from detail

I am using swift

I am using UISplitView. I have a button on the detail page that when clicked, I would like the master view to display. I have tried:

self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.allVisible

but this did not work.

Is there a way to display the master view from a button on the detail page?

Upvotes: 0

Views: 542

Answers (1)

Daryl1109
Daryl1109

Reputation: 66

I use this same code you have and it works fine when called in the in the Detail View Controller.

 @IBAction func showHideLeftPane(sender: AnyObject) {
    if self.splitViewController?.preferredDisplayMode == UISplitViewControllerDisplayMode.AllVisible {            
        self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.PrimaryHidden
    }
    else {
        self.splitViewController?.preferredDisplayMode = UISplitViewControllerDisplayMode.AllVisible
    }

if you do not want the NWSE arrow button placed in the navigation bar..

     override func viewWillAppear(animated: Bool) {
       self.navigationItem.leftBarButtonItems = []
       self.navigationItem.leftItemsSupplementBackButton = false
       super.viewWillAppear(animated)
    }

I hope this helps.

Upvotes: 2

Related Questions