Uisplitviewcontroller Displaymodebuttonitem()

UISplitViewController displayModeButtonItem in iPAD

Set the SplitViewController's preferredDisplayMode to UISplitViewControllerDisplayModeAllVisible and it will appear.

But this will change it in portrait mode too on the iPad, and you probably don't want it there, so you'll have to check when rotating and change it accordingly.

UISplitViewController displayModeButtonItem not displaying

It turns out that I was calling these methods on my UINavigationController instead of my UIViewController.

It is now working properly if I do so.

Trouble using a custom image for splitViewController displayModeButtonItem (UIBarButtonItem) Swift IOS 9

You'll want to make a UIButton and set the image in it and set that as a leftBarButtonItem like so in your -viewDidLoad:

let menuButton = UIButton(type: .Custom)
menuButton.frame = CGRectMake(0, 0, 29, 29)
menuButton.setImage(UIImage(named:"29x29"), forState: .Normal)
menuButton.addTarget(self, action: "menuPressed:", forControlEvents: .TouchUpInside)
let barButton = UIBarButtonItem(customView: menuButton)
navigationItem.leftBarButtonItem = barButton

and in a separate method, perform your action:

func menuPressed(sender: AnyObject) {
//show menu
}

How to name a back button in UISplitViewController

Thanks to Paul Hegarty and his invaluable lectures at Stanford University and available on iTunes U... in this case his 2013 lectures under the title "Developing iOS 7 Apps for iPhone and iPad" and specifically "Lecture 11 Table View and the iPad".

If you're using storyboards, then:

  • Open your main storyboard and select the Navigation Controller that links to the Master View Controller in your Split View Controller group;
  • Open the Inspector;
  • Under the heading View Controller, against the property Title, enter the words that you would like to appear alongside the "Back" button chevron.

See screenshot of Master Detail Xcode template set up with a Split View Controller...

Interface Building screenshot detailing location of "Title" property for Navigation Controller

If you're instantiating views in code, then:

  • obtain a reference to the Navigation Controller for the Master View controller;
  • set the title property of that Navigation Controller with the NSString of words that you would like to appear alongside the "Back" button chevron.

As an aside, I would highly recommend implementation of Auto Layout and Size Classes, that you remove the text for the Back Button property and let size classes determine the appropriate words for your Back Button.

For example, as per the question...

remove text in the "Back Button" property



Related Topics



Leave a reply



Submit