Search code examples
iosobjective-cuiscreen

How to get iOS device screen height and width


Possible Duplicate:
IPhone/IPad: How to get screen width programmatically?
How to get orientation-dependent height and width of the screen?

Accounting for the various iOS devices and orientations, what is the simplest approach to getting the current screen resolution, including height and width?


Solution

  • UIScreen is your friend here.

    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;