Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad modal controller is dismissed after rotation

I am presenting a modal view using a storyboard segue set as Form Sheet. The problem is, when I rotate the iPad after this view is displayed, the view is removed from the view/dismissed.

I have no idea why. It only seems to occur when starting in Portrait then rotating to Landscape.

If I start in Landscape then show the view then rotate it stays on the screen fine.

Any ideas?

EDIT ----

It also seems that full screen modal views are also dismissed after rotation!

There's nothing special going on in the presentation code, this is a full screen modal:

EditViewController *editView = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"editViewController"];
editView.delegate = self;
editView.image = image;
editView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self presentViewController:editView animated:YES completion:nil];

This happens on both iOS 6 and iOS 7

EDIT 2 ---- Forgot to mention, i'm presenting the modal from the left/master view controller of a UISplitViewController

like image 561
Darren Avatar asked Jan 05 '14 16:01

Darren


2 Answers

late, but what it worked for me was just before

[self presentViewController:aController animated:YES completion:nil];

dismiss the master controller, adding this lines

[self.splitViewController setPreferredDisplayMode:UISplitViewControllerDisplayModePrimaryHidden];
[self.splitViewController setPreferredDisplayMode:UISplitViewControllerDisplayModeAutomatic];

and then present your controller

like image 181
JoseGalindo Avatar answered Sep 18 '22 18:09

JoseGalindo


Get rid of: editView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; That will solve the issue you are experiencing. Modal view controllers presented on iPad as a Form Sheet do not rotate correctly using that transition style.

like image 41
Norman G Avatar answered Sep 18 '22 18:09

Norman G