7

This has been troubling me for quite a while, and I have done so much research on this, but could't find an answer. My first time posting a question here, please correct/forgive me if I make a mistake.

Environment: iPad, iOS 6.0

Problem: Base modal view change to full screen after rotation.

Description: I have a full screen application running currently showing a modal view controller. From the showing modal view, I display another modal view by doing:

vc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:vc animated:YES];
//[self presentViewController:vc animated:YES completion:NULL];

While the second view is appearing, and I rotate the iPad device. The base(first) modal view becomes full screen, and the topmost(second) modal view stays in formSheet style. (rotate correctly)

I can fix this by adding modal view to navigationController, but I want to keep it in modal view.

Any one knows a fix? I believe this person here is having the same problem: ios 6 Incorrect modal view size after rotation

Btw, everything works fine in iOS 5. Apple changed the way rotation works in iOS 6. Thanks, -peter

Community
  • 1
  • 1

2 Answers2

4

I found a solution for this problem. Set the last modal view's presentation style to UIModalPresentationCurrentContext before you present it.

Like this:

vc.modalPresentationStyle = UIModalPresentationCurrentContext; [self presentModalViewController:vc animated:YES];

This solves the base modal view change size after rotate the iPad screen.

Originally answered by people on Apple Dev forum.

  • FWIW, this worked great, but I had to set this inside the child view controller, I couldn't set it in prepareForSegue from the presentingVC. – rooftop Jul 02 '14 at 13:56
1

I had the exact same issue and used the code in iOS 6: Parent modal's modalPresentationStyle ignored after rotation worked like a charm

Community
  • 1
  • 1
konop
  • 21
  • 5