iphone - iOS:从多任务栏恢复应用程序时如何保持方向?

标签 iphone ios multitasking screen-orientation snapshot

问题:

如果我在 UIInterfaceOrientationLandscapeRight 方向时将应用程序发送到后台,当我从多任务栏恢复应用程序时,方向是 UIInterfaceOrientationLandscapeLeft,这是默认的,用于显示的快照和 View 。 View 立即通过旋转回被挂起之前的最后一个已知方向 UIInterfaceOrientationLandscapeRight 重新定位自身。

已知数量:

  • 应用支持 2 种界面方向:UIInterfaceOrientationLandscapeLeft 和 UIInterfaceOrientationLandscapeRight
  • 应用程序使用自动旋转所有 View Controller 覆盖 ShouldAutoRotateToInterfaceOrientation,如果方向是支持的方向之一,则返回是
  • 两个方向都在 Info.plist 中的 UISupportedInterfaceOrientations 键
  • 下定义
  • 当应用程序被发送到后台时,会拍摄并存储支持的方向的自动快照
  • 从跳板恢复应用程序按预期工作,方向与发送到后台时相同。

  • 观察到的行为:

    当从多任务栏恢复应用程序时,应用程序会收到 2 个方向通知,这些通知分别由覆盖的 shouldAutoRotateToInterfaceOrientation 评估。首先是 UIInterfaceOrientationLandscapeLeft,然后是 UIInterfaceOrientationLandscapeRight。

    预期成绩:

    从多任务栏恢复应用程序时,方向与暂停时相同。因此,如果我们处于 UIInterfaceOrientationLandscapeRight 模式,那么我希望以相同的方向恢复。

    最佳答案

    我知道这是一篇旧帖子,但答案是您没有定义 key UISupportedInterfaceOrientations在 Info.plist 文件中,值为 UIInterfaceOrientationLandscapeLeftUIInterfaceOrientationLandscapeRight .

    关于iphone - iOS:从多任务栏恢复应用程序时如何保持方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4807707/

    相关文章:

    ios - 没有 Storyboard 的 UIViewController 状态恢复不起作用

    Ios - 尝试将监听器添加到 TextView 时出现语法错误

    java - Java 是否可以在一个线程中并行运行多个任务?

    c# - 异步延迟超时任务

    ios - 如何同时弹出模态视图和上一个导航 Controller View ?

    ios - 词典词典

    ios - ReloadData 在我的 TableViewController 中不起作用

    ios - 如何将 uitextfield 字符范围限制为 10 位

    ios - 如何从 iPhone 本地内存上传图像、pdf、音频、视频和任何文件系统到服务器(API)

    android - Android 中的 float 视频播放器?