2

My application is tab based navigation. I am using Xcode9 with iOS11. For support landscape/portrait compatibility I am using the following method in my all viewControllers.

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

}

But when I rotate the app in first view controller, then automatically call the viewWillTransition method in all other view controllers. How to resolve this issue?

halfer
  • 19,824
  • 17
  • 99
  • 186
IKKA
  • 6,297
  • 7
  • 50
  • 88

1 Answers1

2

It's calling the viewWillTransition method because all the tab view controllers are in the memory at that time.

You can add a check for the current view controller and update it only when it's the right view controller.

Make a boolean value true when viewWillAppear method is called and make it false when viewWillDisappear method will be called.

Mr.Kushwaha
  • 491
  • 5
  • 14