When I use ViewController.View.frame.size.width and height in landscape mode, I am getting 768 and 1024 respectively where as I see 1024 and 768 from my Storyboard's "Size Inspector". Have anyone got any idea why this is happening?
This is an oddity (bug?) in iOS. But I'd wager that so many people have done kludgy workarounds (e.g., inspect the device orientation and if landscape, flip the width and height), that I'm not sure if Apple dare fix this, for fear of breaking tons of apps.
As an example of the strange behavior, if you have a navigation controller, for example, you'll find that the frame.size is correct as you go from portrait to landscape mode, but in the absence of a navigation controller, it isn't. If you're just looking for the width and height, you can frequently grab bounds.size, instead, which appears to get updated properly, regardless.
You cannot use the frame for a view's dimension. You have to use bounds. More info is here: My self.view has the wrong dimensions
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