I'm using viewWillTransitionToSize to adjust my slideout menu when I rotate the device, however it seems to be broken in Swift 3? Can anyone solve this for me? My code looks like this:
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!
})
}
It seems like it doesn't get called when I rotate the device?
Figured out what the problems was, the changes the migration to swift 3 made was not proper, 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!
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With