【问题标题】:Simulator rotation locked模拟器旋转锁定
【发布时间】:2014-05-24 14:28:25
【问题描述】:

我刚刚开始在 Xcode 中为 iOS 7.0+ 创建应用程序的 tutorial。

但是,当我运行应用程序并在 iOS 模拟器 中旋转设备时,应用程序的位置在纵向模式下保持固定,而屏幕确实变为横向大小。这显然不应该发生,因为它只适用于教程。

有人可以帮我解决这个问题吗?

编辑 1: 我已经勾选了所有框,这没有帮助。我还添加了代码

- (BOOL)shouldAutorotateToInterfaceOrientation:        (UIInterfaceOrientation)interfaceOrientation
{

if ( interfaceOrientation == UIInterfaceOrientationLandscapeLeft  || interfaceOrientation   == UIInterfaceOrientationLandscapeRight || interfaceOrientation ==    UIInterfaceOrientationPortrait)
    return YES; // for supported orientations

return NO;
}

这也没有做任何事情,我也已经注意到supported interface orientation 的数组已经存在。可能问题出在 iOS 模拟器

编辑 2:
对不起,我的愚蠢,iOS的旋转锁定出于某种原因...谢谢大家

【问题讨论】:

    标签: ios iphone objective-c xcode ios-simulator


    【解决方案1】:

    这是因为您没有为应用设置横向。

    Xcode 默认设置为仅纵向。

    【讨论】:

    • 我勾选了纵向框,还有横向左侧和右侧横向框(被告知),但是当我旋转屏幕时它仍然不旋转。当我只选择左右横向时,它在横向左侧模式下完美地模拟了应用程序。但是,如果我尝试向右旋转到横向,应用程序仍然固定在横向左侧并且不会旋转。顺便说一句,iPad 模拟器确实会旋转
    • 在您的项目中搜索shouldAutorotateToInterfaceOrientation,如果您有任何代码,请告诉我...如果有,请编辑您的问题并将其发布在此处...
    • 貌似没有这个功能,估计得像其他cmets说的那样自己添加吧?
    • @DanielsWrath :如果您单击了所有 4 个方向选项,那么它应该适用于所有 4 个方向...
    • @DanielsWrath 我面临同样类型的问题。在我的应用程序中,iPhone 模拟器适用于除倒置之外的所有方向。 iPad 上的同一个应用程序适用于所有四个方向。任何指导。
    【解决方案2】:

    打开你的项目,找到 your_projetname-info.plist 文件, 给他添加新行并写在这里

    Supported interface orientations
    

    这将在您的 plist 文件中创建一个以支持的方向作为元素的数组字段。 添加新元素(按+)并从下拉列表方向中选择比您需要的。

    您也可以在代码中执行此操作(您的 AppDelegate) 通过添加

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    
    if ( interfaceOrientation == <needed_interface_orientation> || interfaceOrientation ==<another_needed_interfaceOrientation>)
            return YES; // for supported orientations
    
    return NO;
    }
    

    在此之后,您必须阅读苹果自动布局指南(链接建议由

    极光)

    【讨论】:

    • 我如何快速做到这一点?
    【解决方案3】:

    您需要了解自动布局,更具体地了解如何设置约束。

    有关于自动布局的 Ray 的 Video Tutorial 和适用于 iOS 7 的 Beginning Auto Layout 博客文章。也许你给丰富的 Apple 文档一个机会:Auto Layout Guide

    编辑 - 好的,我的回答被否决了。这意味着我应该举一个例子 - 可能是重复的问题。当我制作我的第一个应用程序时,我遇到了同样的问题。截图如下,你是不是在同一条船上?

    【讨论】:

    • 谢谢,我想通了,旋转被锁定在模拟器中...但是感谢教程的链接,我会看看那些!
    猜你喜欢
    • 2012-02-22
    • 2023-03-24
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 2011-04-07
    • 1970-01-01
    相关资源
    最近更新 更多