【问题标题】:Landscape orientation of a single viewController in iphone appiPhone应用程序中单个viewController的横向方向
【发布时间】:2013-05-24 00:44:15
【问题描述】:

我需要我的 iphone 应用程序的所有视图都处于纵向模式,除了一个。

我有一个列表视图控制器(视图 1),单击时会显示详细视图(视图 2)。
在详细视图上,我有一个按钮,它触发了一个模式 segue,它应该在横向模式下显示一个视图(视图 3)。

在 XCode 中,我已将视图 1 和 2 的方向设置为纵向,我已将视图 3 设置为横向。

应用程序启动时,视图 1 以纵向模式显示,但当我更改方向时,它切换到横向,我需要它保持纵向。

当我单击视图 2 的按钮时,视图 3 以纵向模式显示(这是我唯一需要的横向模式)。

视图 1 和 2 有:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  // Return YES for supported orientations
  return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

视图 3 有:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  // Return YES for supported orientations
  return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}

视图 1 和视图 2 始终为纵向,视图 3 始终为横向,缺少什么配置?

编辑

我最终将应用程序方向保留为纵向,并使用通知事件来旋转我需要的横向视图。像这样工作得很好。

【问题讨论】:

    标签: ios orientation uiinterfaceorientation


    【解决方案1】:

    如果您在 iOS 6 下运行,则 shouldAutorotateToInterfaceOrientation 已被弃用。您应该使用supportedInterfaceOrientationsForWindow:shouldAutorotate 方法。

    查看 UIKit 标题下的 iOS 6 发行说明here

    【讨论】:

      【解决方案2】:

      您要为 iOS6 实现的是 UIViewController 上的 supportedInterfaceOrientations,而不是 shouldAutorotateToInterfaceOrientation

      【讨论】:

        猜你喜欢
        • 2014-09-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-12
        • 1970-01-01
        • 2012-04-23
        相关资源
        最近更新 更多