iPad 中未调用 supportedInterfaceOrientations

supportedInterfaceOrientations not called in iPad

我有一个 UITabBarController 子类,它有以下代码:

class TabBarController: UITabBarController {

// MARK: Methods

override func viewDidLoad() {

    super.viewDidLoad()

}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {

    print(self.selectedIndex)
    if self.selectedIndex == 1 {
        return .Portrait
    }

    return .All


   }

}

仅当我从 iphone 执行应用程序时才调用函数 supportedInterfaceOrientations。如果我从我的 iPad mini 执行应用程序,它不会被调用。知道这种行为的原因吗?

这很奇怪,但是如果我从 iPad 的设备方向中取消选择 Upside Down,则会调用 supportedInterfaceOrientations

更新:

如果启用 'General' 中的 'Requires full screen' 设置,将允许触发方向委托方法 shouldAutorotatepreferredInterfaceOrientationsupportedInterfaceOrientations