锁定方向不适用于ipad ios 8 swift xcode 6.2 [英] locking orientation does not work on ipad ios 8 swift xcode 6.2

查看:107
本文介绍了锁定方向不适用于ipad ios 8 swift xcode 6.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将应用方向锁定为来自常规应用设置的肖像

I locked the app orientation to portrait from the general app setting like this

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

but still when i run my application on ipad, it rotates!?

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

so where should i lock the orientation ?

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

why apple added this feature to settings, while it is not working !?

UPDATE:

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

I tried to implement this viewController as the general for all the viewController as well.

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
    }
}

此照片拍摄从我的应用程序的主导航控制器。

this pic taken from the main navigationController of my app.

仍然无法正常工作!

这个东西怎么样?

推荐答案

你不需要额外的代码,我正在研究Xcode 7.0.1,我注意到当我将屏幕方向锁定为只有肖像时,它只能锁定在iPhone中,也可以锁定在iPad上,你需要从设备中选择iPad(而不是通用)并检查肖像并取消选中其他设备,然后再将设备返回到环球,因为我发现环球仅反映在iPhone中,它可能是Xcode中的某种错误。

You don't need extra code, I'm working on Xcode 7.0.1, I noticed that when I lock screen orientation to only portrait, it locks only in iPhones, to lock it in iPads also, you need to select iPad from Devices (instead of Universal) and check portrait and uncheck the others and then return Devices to Universal again, as I found that Universal only reflect in iPhones, it maybe some kind of bug in Xcode.

这篇关于锁定方向不适用于ipad ios 8 swift xcode 6.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆