ios - 锁定方向不适用于 ipad ios 8 swift xcode 6.2

标签 ios iphone swift

我从这样的一般应用设置中将应用方向锁定为纵向

portrait

但是当我在 ipad 上运行我的应用程序时,它仍然在旋转!?

那么我应该在哪里锁定方向?

为什么苹果将此功能添加到设置中,但它不起作用!?

更新:

我也尝试将此 viewController 实现为所有 viewController 的通用。

import Foundation
import UIKit

class GeneralViewController: UIViewController {

    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        let value = UIInterfaceOrientation.Portrait.rawValue
        UIDevice.currentDevice().setValue(value, forKey: "orientation")
    }

    override func supportedInterfaceOrientations() -> Int {
        return Int(UIInterfaceOrientationMask.Portrait.rawValue)
    }


    override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
        return UIInterfaceOrientation.Portrait
    }

    override func shouldAutorotate() -> Bool {
        return false
    }
}

这张图片取 self 应用的主导航 Controller 。

Pic of answer 1

还是不行!

这到底是怎么回事?

最佳答案

您不需要额外的代码,我正在使用 Xcode 7.0.1,我注意到当我将屏幕方向锁定为仅纵向时,它仅在 iPhone 中锁定,要在 iPad 中也锁定它,您需要选择从 Devices(而不是 Universal)中选择 iPad 并检查纵向并取消选中其他,然后再次将 Devices 返回到 Universal,因为我发现 Universal 仅反射(reflect)在 iPhone 中,这可能是 Xcode 中的某种错误。

关于ios - 锁定方向不适用于 ipad ios 8 swift xcode 6.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55490424/

相关文章:

iphone - 自定义 UITabBar 选定的标签图像,iOS 5 及更高版本

ios - Xcode 项目文件未出现在项目导航器中

ios - UITableView 内容卡在 UINavigationBar 下,可能是由 scrollEdgeAppearance 引起的?

ios - Swift 3 - 如何在相机 View 上显示边框?

ios - 将 JSON 分离到 uitableview 部分

ios - 两个单独的 UIButtons 共享相同的按下...不能同时按下两个

iphone - 在 UITableViewCell 中编辑 TextLabel

ios - ios-输入时替换/删除UITextView中的字符[•]

swift - 授予 OSX 沙盒查找器同步扩展持久写入访问权限

ios - UILabel 子类在使用约束时不显示