orientation-changes
Mobile viewport height after orientation change
Use the resize event The resize event will include the appropriate width and height after an orientationchange, but you do not want to listen for all resize events. Therefore, we add a one-off resize event listener after an orientation change: Javascript: window.addEventListener(‘orientationchange’, function() { // After orientationchange, add a one-time resize event var afterOrientationChange = … Read more
How to detect orientation change?
Here’s how I got it working: In AppDelegate.swift inside the didFinishLaunchingWithOptions function I put: NotificationCenter.default.addObserver(self, selector: #selector(AppDelegate.rotated), name: UIDevice.orientationDidChangeNotification, object: nil) and then inside the AppDelegate class I put the following function: func rotated() { if UIDeviceOrientationIsLandscape(UIDevice.current.orientation) { print(“Landscape”) } if UIDeviceOrientationIsPortrait(UIDevice.current.orientation) { print(“Portrait”) } } Hope this helps anyone else! Thanks!