我的应用有Tabbar
和Navigation
个选项。我的问题是,当设备转为横向时,之前的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
}
}
有任何想法或帮助吗?