【问题标题】:iPhone Modal View Controller and Device OrientationiPhone 模态视图控制器和设备方向
【发布时间】:2011-11-29 09:49:01
【问题描述】:

我快疯了。我有两个支持设备方向的视图控制器(A 和 B)。

  • 在 A 纵向模式下,我以模态方式呈现 B => 运行良好
  • 在 A 横向模式下,我以模态方式呈现 B => 不工作
  • 在 B 中时,如果我更改设备方向并关闭它 => 不起作用

“不工作”是指显示的屏幕与预期不符(图形对象未放置在应在的位置,或未出现在屏幕上)。我不知道我应该怎么做才能防止这种情况发生。

请帮忙!

【问题讨论】:

    标签: iphone modalviewcontroller uiinterfaceorientation presentmodalviewcontroller device-orientation


    【解决方案1】:

    进入界面巨石,在尺寸检查器中,为您的视图设置自动调整大小规则。并且不要忘记将它们设置为自动调整大小。 另外,您可以使用 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 方法在设备方向更改时设置视图坐标

    【讨论】:

    • 感谢 SentineL。但我已经在这样做了。如果你愿意,我在我的一个视图控制器中,更改设备方向正确调整大小并将对象放置在视图中。当我从一个视图控制器移动到另一个视图控制器时出现问题(使用 presentModalViewController 和dismissViewController)
    • 尝试调用 - (BOOL)shouldAutorotateToInterfaceOrientation in viewWillAppear
    • 我试过了,但还是不行。当我关闭我的视图控制器 B 时,按顺序调用视图控制器 A:shouldAutorotateToInterfaceOrientation:UIDeviceOrientationPortrait(这是我展示 B 视图控制器时的设备方向)。然后查看将出现。在里面我添加了 [self shouldAutorotateToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation];所以称为 shouldAutorotateToInterfaceOrientation:UIDeviceOrientationLandscape (我在关闭 B 视图控制器时的设备方向)。但事实上,同样的事情发生了。希望不要混淆^^
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多