ViewWillTransitionToSize broke in Swift 3?

I use viewWillTransitionToSize to adjust my output menu when I rotate the device, however it seems to be split into Swift 3? Can anyone solve this for me? My code is as follows:

func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) coordinator.animate(alongsideTransition: nil, completion: { _ in let controller = self.revealViewController().rightViewController var frame = controller?.view.frame frame?.size.height = UIScreen.main.bounds.size.height - self.navigationController!.navigationBar.frame.size.height - self.toolBar.frame.size.height - (UIApplication.shared.isStatusBarHidden ? 0 : 20) controller?.view.frame = frame! }) } 

Doesn't it seem to be called when I rotate the device?

+7
ios swift swift3
source share
1 answer

It turned out what were the problems, the migration changes in swift 3 were wrong, and the function should look like this:

 override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) coordinator.animate(alongsideTransition: nil, completion: { _ in let controller = self.revealViewController().rightViewController var frame = controller?.view.frame frame?.size.height = UIScreen.main.bounds.size.height - self.navigationController!.navigationBar.frame.size.height - self.toolBar.frame.size.height - (UIApplication.shared.isStatusBarHidden ? 0 : 20) controller?.view.frame = frame! }) } 
+13
source share

All Articles