Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View presented from master panel of UISplitViewController not rotating when rotated from portrait to landscape (iPad)

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.enter image description here
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?

like image 472
Shashikant More Avatar asked Jul 28 '16 10:07

Shashikant More


1 Answers

There are two solutions to resolve the issue:

  1. 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
    
  2. 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.

like image 122
SHN Avatar answered Sep 19 '22 06:09

SHN