2

My application has Tabbar and Navigation options. My problem is, when device is rotating to landscape, previous viewcontroller viewwilltransitiontosize is also calling

Let's explain the scenario,

The first screen is AssignmentViewController The second screen is SubmissionListViewController

Both class I have override viewwilltransitiontosize method. when I rotate to landscape in the 2nd view controller time, it first calls AssignmentViewController's viewwilltransitiontosize method then it calls SubmissionListViewController's viewwilltransitiontosize

here is my piece of code

     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
    }

}

any idea or help please?

Reinier Melian
  • 20,519
  • 3
  • 38
  • 55
Piraba
  • 6,974
  • 17
  • 85
  • 135
  • 1
    Both your view controllers are loaded, so both will be notified of rotation changes. You could check if your view is actually visible before running any code. – James P Jun 29 '16 at 14:46
  • I'm having the same issue. Did you figure this out? – user2621075 Feb 24 '17 at 02:37

0 Answers0