如何仅在iOS中制作一个ViewController肖像

时间:2016-10-24 10:05:17

标签: ios uiviewcontroller swift3

我有一个应用程序支持用于iPad的bot肖像和横向以及仅用于iPhone的肖像。我喜欢将一个ViewController设为仅适用于iPad的肖像。这可能吗?

1 个答案:

答案 0 :(得分:0)

在所有ViewController中添加它

if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone)
    {
        func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
            return UIInterfaceOrientationMask.portrait
        }
    }
    else 
    {
        func shouldAutorotate() -> Bool {
            return true
        }


    }