I'm running the same code on an iPhone 6 plus and an iPad Pro and they don't react the same way. A function is called when the device orientation change and then I'm just printing the width of the view with the following code :
override func viewDidLoad(){
super.vewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(MyClass.rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
}
func rotated(){
print(self.view.bounds.width)
}
On iPhone I get the width after the rotation but on iPad I get the width before the rotation. Thanks for your help!
You can try to get the width in the View Controller Function:
func viewDidLayoutSubviews()
Let me know if this helps!
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