How to get iOS device screen height and width

colindunn picture colindunn · Jan 3, 2013 · Viewed 45.6k times · Source

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?

Answer

Srikar Appalaraju picture Srikar Appalaraju · Jan 3, 2013

UIScreen is your friend here.

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