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...
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...
Related Topics
Example of Dispatch_Once in Swift
Insertion-Order Dictionary (Like Java's Linkedhashmap) in Swift
Include an Extension for a Class Only If iOS11 Is Available
Swift Safe Area Layout Guide and Visual Format Language
Pause an Skaction in Spritekit with Swift
Realm Mobile Platform, How to Connect While Offline
Type Ccc Doesnt Conform to Protocol 'Nsobjectprotocol'
Detail View Is Not Updated When the Model Is Updated (Using List) Swiftui
Detecting If Wifi or Bluetooth Is Turned on or Off by the User
How to Make Apple Sign in Revoke Token Post Request
Binary Operator '+' Cannot Be Applied to Two 'T' Operands
Simple Clickable Link in Cocoa and Swift
Swift: How to Change a Property's Value Without Calling Its Didset Function
How to Set Countdowntimer Mode in Datepicker on Swiftui
How to View Value of Swift "Let" Constant in Xcode 6 Debugger