相关疑难解决方法(0)

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

我将应用方向锁定为像这样的常规应用设置中的纵向

肖像

但是当我在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
    }
}
Run Code Online (Sandbox Code Playgroud)

这张照片取自我的应用程序的主导航控制器.

回答1的Pic

还是没用!

这个东西怎么样?

iphone ios swift

26
推荐指数
4
解决办法
8310
查看次数

在iOS6中的单个UIViewController上禁用自动旋转

我有一个项目使用UINavigationControllersegues工作正常,所有这些都正确旋转,事情是......我只是想禁用autorotation特定的UIViewController.我试过这个:

- (BOOL)shouldAutorotateToInterfaceOrientation:
                               (UIInterfaceOrientation)interfaceOrientation {    
    return NO;
}

// New Autorotation support for iOS 6.
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0){
    return NO;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我UIViewController会自动旋转,欢迎任何帮助:)

xcode objective-c uiinterfaceorientation autorotate ios6

19
推荐指数
3
解决办法
3万
查看次数