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?
When I use ViewController.View.frame.size.width and height in landscape mode, I am getting 768 and
Share
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
widthandheight), 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.sizeis 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 grabbounds.size, instead, which appears to get updated properly, regardless.