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

心不动则不痛 提交于 2019-12-08 19:15:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!