模型视图的 iPad 方向问题
我在主视图中有按钮,当我单击主视图按钮时,模型视图 Mv1 打开。Mv1 模型视图宽度和高度为 730 和 620。在纵向模式下,Mv1 模型视图在主视图中显示中心,但在横向模式下,Mv1 模型视图显示水平居中,但在主视图中不显示垂直居中。
主视图按钮单击编码:-
Mv1 *Mv1obj = [[Mv1 alloc]initWithNibName:@"Mv1" bundle:nil];
UINavigationController*nav[[UINavigationControlleralloc]initWithRootViewController:Mv1obj];
nav.modalPresentationStyle=UIModalPresentationFormSheet;
nav.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:nav animated:YES];
nav.view.superview.frame = CGRectMake(0, 0,730,620);
nav.view.superview.center = self.view.center;
如果知道请重播,提前致谢。
I have button in main view,when i click on main view button model view Mv1 is open.Mv1 model view width and height is 730 and 620.in portrait mode Mv1 model view show center in main view but in landscape mode Mv1 model view show center horizontally but does not show center vertically in main view.
main view button click coding:-
Mv1 *Mv1obj = [[Mv1 alloc]initWithNibName:@"Mv1" bundle:nil];
UINavigationController*nav[[UINavigationControlleralloc]initWithRootViewController:Mv1obj];
nav.modalPresentationStyle=UIModalPresentationFormSheet;
nav.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:nav animated:YES];
nav.view.superview.frame = CGRectMake(0, 0,730,620);
nav.view.superview.center = self.view.center;
if know please replay,thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的问题是,您在设置中心时需要考虑方向,因此将行:
nav.view.superview.center = self.view.center;
替换为类似这样的内容
将正确居中模态视图。
The issue here is that you need to account for orientation when setting the center, so replace the line:
nav.view.superview.center = self.view.center;
with something like
this will correctly center the modal view.