如何在Landscape视图中显示第二个子viewController(parent - > child - > child(Landscape))嵌套子

时间:2017-05-27 13:37:56

标签: ios swift3 landscape

我试图在横向上只强制一个viewController,需要在横向视图中[Parent - >孩子 - >景观中的孩子]。

以下是我的代码:

来自父viewController的

呈现第一个viewController(第一个孩子)

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: ControllerStoryboardName.player.description) as! FirstViewController
self.present(vc, animated: true, completion: nil)

然后从第一个viewController呈现第二个viewController(第二个孩子)

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: ControllerStoryboardName.player.description) as! SecondViewController
self.present(vc, animated: true, completion: nil)

我需要以横向模式显示的第二个viewController。下面是我对force landscape的第二个viewController覆盖方法:

override var shouldAutorotate: Bool {
        return true
}

override var supportedInterfaceOrientations: UIInterfaceOrientationMask{
        return UIInterfaceOrientationMask.landscape
}

我的appDelegate方法:

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        if self.window?.rootViewController?.presentedViewController is SecondViewController {
            return UIInterfaceOrientationMask.all
        }else{
            return UIInterfaceOrientationMask.portrait
        }
    }

从父母到单身儿童在横向模式下工作正常,但是当我尝试从父母到孩子,然后在横向模式下的孩子不是在按摩。第二个孩子以纵向模式呈现需要处于横向模式。怎么实现这个? 任何帮助都会得到赞赏。

0 个答案:

没有答案