Multiple MODAL VIEW controller change base modal to FULL SCREEN after ROTATION
Asked Answered
S

2

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

Socialism answered 24/10, 2012 at 22:49 Comment(0)
S
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.

Socialism answered 20/2, 2013 at 21:12 Comment(1)
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.Selfinsurance
R
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

Radiance answered 24/1, 2013 at 6:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.