2

I've studied examples of split view (like this one) and it works great. I just need one change of behavior. I would like to have both master and detail controller visible when user have iPad in portrait. It should work just like FB Messenger or Skype. Both controllers side-by-side and without able to hide master controller. How is it possible to do that? Thanks for help

Bonus question: Is it possible to somehow set behavior for iPad portrait be same like iPhone portrait? If I would change my mind and I would like to have detail in fullscreen and after tap on left navigation bar button I would have master view in fullscreen and without detail visible. Is i possible or split view decides that and there is not much what I can do about it?

Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182

1 Answers1

7

A UISplitViewController has a property called preferredDisplayMode. You can set this to any one of these values:

  1. UISplitViewControllerDisplayModeAutomatic
  2. UISplitViewControllerDisplayModePrimaryHidden
  3. UISplitViewControllerDisplayModePrimaryOverlay
  4. UISplitViewControllerDisplayModeAllVisible

You are looking for UISplitViewControllerDisplayModeAllVisible.

[self.splitViewController setPreferredDisplayMode:UISplitViewControllerDisplayModeAllVisible];

UISplitViewControllerDisplayModeAllVisible

The primary and secondary view controllers are displayed side-by-side onscreen.

Available in iOS 8.0 and later.

You can read more about the display modes here on Apple's documentation.

j.f.
  • 3,908
  • 2
  • 29
  • 42
  • Thanks for answer. I know about this but when I used it I was still able to hide master (left) controller. But I was digging deep and I find out that's because I set as in tutorial: `detailViewController.navigationItem.leftItemsSupplementBackButton = true detailViewController.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem()` so after removing this I have it as I want. – Libor Zapletal Oct 16 '15 at 14:54
  • So just for bonus question. Do you know if it is possible to set same layout in iPad portrait as iPhone portrait? Controller with fullscreen? If it is possible to manipulate with width dimension where is changing layout. – Libor Zapletal Oct 16 '15 at 14:59
  • Yep, you just need to play with the display modes. Switching between PrimaryHidden and PrimaryOverlay will bounce you back and forth between showing the primary or the secondary on screen. I believe when you use AllVisible on the iPhone, that is actually the behavior. iPhone cannot display both at the same time so behind the scenes it switches between hidden and overlay for you. – j.f. Oct 16 '15 at 15:03
  • Nope, in this you aren't right. It just sets primary controller as overlay and sets if it is initially display or hidden. – Libor Zapletal Oct 16 '15 at 15:12