Libor Zapletal
Libor Zapletal

Reputation: 14102

UISplitViewController - set always visible master controller when

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?

Upvotes: 2

Views: 2623

Answers (1)

j.f.
j.f.

Reputation: 3949

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.

Upvotes: 8

Related Questions