简体   繁体   English

更改方向后,iOS8无法重新调整模态表单的大小

[英]iOS8 unable to re-size the modal form sheet after changing the orientation

Actually what i am doing is on iPad i am presenting the modal form sheet with my own size (520 X 400). 实际上我正在做的是在iPad上我正在呈现具有我自己尺寸(520 X 400)的模态表单。 It was working fine at first time. 它第一次工作正常。 Then when i do rotate (portrait to landscape or landscape to portrait) my modal form sheet changed to ios default size. 然后,当我旋转(纵向到横向或横向到纵向)时,我的模态表单更改为ios默认大小。 Also, i was not able to change the modal form sheet size again by programatically. 此外,我无法通过编程方式再次更改模态表单大小。 Since, once the orientation changed ios making my (520X400) modal form sheet to its default size. 因为,一旦方向改变了ios使我的(520X400)模态表格到其默认大小。 Any idea how to fix this?. 知道怎么解决这个问题吗?

当我第一次展示我的模态时的截图

我更改设备方向时的屏幕截图

Note: 注意:

When i ran on ios7 device i not am seeing any issue with the following code. 当我在ios7设备上运行时,我没有看到以下代码的任何问题。 If any thing wrong with my code then please indicate me. 如果我的代码有任何问题,请指出我。 Since i do not know what's wrong with ios8 因为我不知道ios8有什么问题

Here is the code that was i used to change the modal form sheet size: 这是我用来更改模态表单大小的代码:

self.navigationController.view.superview.frame = CGRectMake(200, 220, 400, 605);

finally i figure out a way how to resolve the above one. 最后我找到了解决上述方法的方法。

Here my solution: 我的解决方案:

on ios8 just setting the following property to your modal view will resolve the issue 在ios8上只需将以下属性设置为模态视图即可解决此问题

in view did load: 在视图中加载:

CGRect rect = self.navigationController.view.superview.bounds;
rect.size.width = 605;
rect.size.height = 350;
self.navigationController.view.superview.bounds = rect;
self.navigationController.preferredContentSize = CGSizeMake(605, 350);

before presenting your modal view 在展示你的模态视图之前

your_modal_view.preferredContentSize = CGSizeMake(540.0f, 620.0f) //what ever the size you want

I hope this helps 我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM