IOS viewwilltransitiontosize方法在旋转时调用所有viewcontroller

时间:2016-06-29 14:41:49

标签: ios swift ios-autolayout

我的应用有TabbarNavigation个选项。我的问题是,当设备转为横向时,之前的viewcontroller viewwilltransitiontosize也在调用

让我们解释一下情景,

第一个屏幕是AssignmentViewController    第二个屏幕是SubmissionListViewController

这两个课都有覆盖viewwilltransitiontosize方法。当我在第二个视图控制器时间旋转到横向时,它首先调用AssignmentViewController's viewwilltransitiontosize方法,然后调用SubmissionListViewController's viewwilltransitiontosize

这是我的代码

     override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
    if UIDevice.currentDevice().orientation.isLandscape.boolValue {
        print("Landscape")
        self.navigationController?.setNavigationBarHidden(true, animated: false)
        self.landscapeVideo()
        self.tabBarController!.tabBar.hidden = true
    } else {
        print("Portrait")
        self.navigationController?.setNavigationBarHidden(false, animated: false)
        self.videoinPortraitMode()
        self.tabBarController!.tabBar.hidden = false
    }

}

有任何想法或帮助吗?

0 个答案:

没有答案