1

I have this application which uses internally a UISplitViewControler to display the main interface. The problem I have is that on IOS7 I don't see the button on the left to open the master panel.

The theory says that I have to set the delegate and the button will appear. In practice - my delegate is not called in IOS7. It does on IOS8.

First try:

  1. I am following the normal double navigation controller scheme (described here: http://whoisryannystrom.com/2014/11/17/UISplitViewController-iOS-7/)
  2. Code is swift :)
  3. As I need my app to work on IOS7 phones, in am not creating the split view controller in code, but using the one in the storyboard:

(somewhere in app delegate):

UIStoryboard *board = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
UIViewController *newController = [board instantiateViewControllerWithIdentifier:@"LoginViewController2"];
self.window.rootViewController = newController;
  1. The delegate is created in the master, and assigned to master. This works on IOS8.

Code in the master

override func akaweFromNib() {
    super.awakeFromNib()
    if let splitViewController = self.splitViewController {
        let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as UINavigationController
        if  (splitViewController.respondsToSelector(Selector("displayModeButtonItem"))) {
            navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
        }
        splitViewController.delegate = self       
    }
}

This works, but I have to open the drawer and choose something on the master view (create a new segue) in order to see the button.


Second try

As this did not work - I created a new UISplitViewController and set the split view controller on the storyboard to this new class. Move the onWakeFromNib to this new class (and set the delegate as before). New code works on IOS8, but under IOS7 (at least on the IPad Emulator) the new class is not used for the split view controller - I don't hit a breakpoint in the new code.

What am I doing wrong?


Edit:

While copying code here, I forgot to mention that I am doing:

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

But - this is only available in IOS8. What can I do in IOS7?

2015-02-12 10:37:55.987 OlympiaTracking[92551:607] -[UISplitViewController displayModeButtonItem]: unrecognized selector sent to instance 0x7b67f1c0

Edit 2: I also followed ios7 no displayModeButtonItem or targetDisplayModeForActionInSplitViewController which works, but only after the first segue. When the controller is first displayed, the button is not visible.

Community
  • 1
  • 1
elcuco
  • 8,948
  • 9
  • 47
  • 69

1 Answers1

0

Open this link and move to the iPad part. Where it says

Notice that when the iPad app is first opened up, there is no indication that this is a split view controller at all! To trigger the Master view controller, the user has to magically know to swipe left to right.

Even when the navigation controller is in place, the UI is not that much better at first glance (although seeing a title is definitely an improvement):

Michal Shatz
  • 1,416
  • 2
  • 20
  • 31