I'm using a UISplitViewController with a triple column style, with .displayMode set to .twoBesideSecondary in order to show all 3 columns. In landscape, there is plenty of room on iPad to display all 3 columns.
In portrait orientation, or when there's another app on screen in side-by-side multitasking, the screen is too narrow, and my 3rd column ("secondary" view controller) gets completely squished to a very narrow width. What I would like to do is switch the .displayMode property to .twoDisplaceSecondary in these cases so that the content in the secondary VC gets pushed off screen, rather than squished.
A great example of exactly what I want to do is the Contacts app on iPad. When in landscape, all 3 columns are fully shown. When an app is brought on screen for multitasking, it is detected somehow and the .displayMode changes to .twoDisplaceSecondary, and the 3rd column is pushed off screen rather than getting squished.
I think I know how to manage detecting orientation changes (using viewWillTransitiontoSize) so I can manage landscape vc. portrait displayMode, but I'm not sure how to detect when another app is present in multitasking.
Thanks!
In portrait orientation, or when there's another app on screen in side-by-side multitasking, the screen is too narrow, and my 3rd column ("secondary" view controller) gets completely squished to a very narrow width. What I would like to do is switch the .displayMode property to .twoDisplaceSecondary in these cases so that the content in the secondary VC gets pushed off screen, rather than squished.
A great example of exactly what I want to do is the Contacts app on iPad. When in landscape, all 3 columns are fully shown. When an app is brought on screen for multitasking, it is detected somehow and the .displayMode changes to .twoDisplaceSecondary, and the 3rd column is pushed off screen rather than getting squished.
I think I know how to manage detecting orientation changes (using viewWillTransitiontoSize) so I can manage landscape vc. portrait displayMode, but I'm not sure how to detect when another app is present in multitasking.
Thanks!
For any future readers:
I figured out that it's important to set BOTH .preferredDisplayMode and .preferredSplitBehavior when the view transitions. Setting just one or the other will result in lots of weird behavior.
What I figured out works for this case is setting preferredDisplayMode = .twoBesideSecondary and preferredSplitBehavior = .tile when the screen is wide enough to fit all 3 columns, and when it is not, set preferredDisplayMode = .oneBesideSecondary and preferredSplitBehavior = .displace.
I used a function that checks if the view.frame.size.width < 1194 to determine if the screen is full width or not, as using orientation only would cause problems if the app is side by side with another. I'll probably tweak that value over time so don't take it as gospel, but it works for now. I call this function in viewDidLoad for initially setting the behaviors, then again in viewWillTransition(toSize:), using the size property there to update the behaviors.
I figured out that it's important to set BOTH .preferredDisplayMode and .preferredSplitBehavior when the view transitions. Setting just one or the other will result in lots of weird behavior.
What I figured out works for this case is setting preferredDisplayMode = .twoBesideSecondary and preferredSplitBehavior = .tile when the screen is wide enough to fit all 3 columns, and when it is not, set preferredDisplayMode = .oneBesideSecondary and preferredSplitBehavior = .displace.
I used a function that checks if the view.frame.size.width < 1194 to determine if the screen is full width or not, as using orientation only would cause problems if the app is side by side with another. I'll probably tweak that value over time so don't take it as gospel, but it works for now. I call this function in viewDidLoad for initially setting the behaviors, then again in viewWillTransition(toSize:), using the size property there to update the behaviors.