Reputation: 304
I am presenting a modal view and action sheet from master panel of UISplitViewController
. iOS 9.3
1) If I present the view when the iPad is in portrait mode and rotate the iPad to landscape, then the screen is not rotating.
2) But if I present the view when the iPad is in landscape mode and rotate the iPad to portrait, then the screen is rotating.
How can I achieve the rotation?
Upvotes: 10
Views: 520
Reputation: 795
There are two solutions to resolve the issue:
It is not ideal to present modal views from master panel but you should be doing it from the UISplitViewController itself.
splitViewController.preferredDisplayMode =UISplitViewControllerDisplayModeAllVisible; // For displaying the master panel always as is in the screen shot in the Question
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet; // For displaying the modalViewController in form sheet style
[splitViewController presentViewController:modalViewController animated:TRUE completion:nil]; // Note: modalViewController is presented from UISplitViewController and not from master panel of split view
The master panel of spilt view is presented in a popover when in portrait mode so the device rotation changes have to go through popovercontroller. I am guessing the chain breaks at this points. So, to resolve the issue call
[spliVC setPreferredDisplayMode:UISplitViewControllerDisplayModePrimaryHidden];
before the modal presentation segue is called(from prepareForSegue
). I am not sure of whether delegates working with this approach.
EDIT:
I have also observed that if the Split view is in UISplitViewControllerDisplayModeAllVisible
mode then even presenting modal vc from master panel(lets say by a simple modal segue in storyboard) does not give the rotation issue. I have confirmed this in iOS 9.3 simulator.
Upvotes: 1