ViewWillTransitionToSize is called on all view controllers

The viewWillTransitionToSize method is called when the device is oriented. The problem is that this is being called on all view controllers. If the view controller A initiates the view controller B with the click of a button and then rotates the device, the viewWillTransitionToSize method from A. is also called. How to disable this?

+4
source share
1 answer

You need to add

super.viewWillTransitionToSize (size, withTransitionCoordinator: coordinator) handleLevelOrientation ()

inside your viewWillTransitionToSize function. Here is my code:

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

        handleLevelOrientation()            
    }

viewDidLoad, , viewWillTransitionToSize .

-1

All Articles