【问题标题】:UIView with landscape only is turning to portrait仅具有横向的 UIView 正在转向纵向
【发布时间】:2012-04-11 05:18:17
【问题描述】:

所以我让我的应用运行 iPad 的主从项目。

我在节目中添加了UIBarButtonItem,将视图“关于应用程序”推送到详细信息。

当我将第三个视图推送到细节(来自UITable)并点击后退按钮时,它会返回到 navigationControl 堆栈上的第二个视图,并且视图会变成纵向!

我所有的 viewController 都有以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    else
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

这是出现的错误:

视图控制器返回 NO from -shouldAutorotateToInterfaceOrientation: 对于所有接口 方向。它应该至少支持一个方向。

我还尝试直接从情节提要中将横向设置为 UIView 方向,但也不起作用。

有什么线索吗?

【问题讨论】:

  • 在对其他问题进行了几次测试后,我意识到我在情节提要上的 About 视图类没有指向我的 AboutViewController.m 类。抱歉这个愚蠢的问题。

标签: objective-c xcode ipad orientation storyboard


【解决方案1】:

我会尝试删除 if 语句以进一步检查问题的原因,只留下 isLandscape 签入。

【讨论】:

    【解决方案2】:

    过了一会儿,我意识到我的第三个视图的代码略有不同。

    我刚刚从其他视图中复制了代码并粘贴到第三个视图中,现在它正在工作......

    【讨论】:

      猜你喜欢
      • 2012-03-29
      • 2012-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 2018-03-22
      • 2014-09-16
      相关资源
      最近更新 更多