Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get iOS device screen height and width [duplicate]

Tags:

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?

like image 545
colindunn Avatar asked Jan 03 '13 08:01

colindunn


People also ask

How can I get mobile screen width and height?

Display display = getWindowManager(). getDefaultDisplay(); Point size = new Point(); display. getSize(size); int width = size. x; int height = size.

How do I find the width of my device?

You can get the device screen width via the screen. width property. Sometimes it's also useful to use window. innerWidth (not typically found on mobile devices) instead of screen width when dealing with desktop browsers where the window size is often less than the device screen size.

How do I find my screen width and height in Swiftui?

main. bounds. height I get the main screen width and height which is constant. So based on the situation you can use any of these two solutions.


1 Answers

UIScreen is your friend here.

CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width; CGFloat screenHeight = screenRect.size.height; 
like image 144
Srikar Appalaraju Avatar answered Sep 17 '22 12:09

Srikar Appalaraju