问题
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
回答1:
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.
回答2:
I had the exact same issue and used the code in iOS 6: Parent modal's modalPresentationStyle ignored after rotation worked like a charm
来源:https://stackoverflow.com/questions/13059017/multiple-modal-view-controller-change-base-modal-to-full-screen-after-rotation