IOS - how do I find the screen size of the user’s device?

Asked

Viewed 123 times

0

I wonder if there is a way to find out the screen size that the user is using or the model of your iPhone via Objectice-C.

  • 1

    Answer here. http://stackoverflow.com/questions/5677716/how-to-get-the-screen-width-and-height-in-ios

1 answer

1


To find out the screen size in points, you can use the method bounds:

CGRect screenBounds = [[UIScreen mainScreen] bounds];

If you want to know the screen size on pixels, you need to discover the stopover of the screen. For example, older phones will have the scale 1.0, those with the retina screen 2.0, and the larger ones (e.g. iPhone 6 Plus) 3.0.

CGFloat screenScale = [[UIScreen mainScreen] scale];

And then convert from points for pixels:

CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);

Source (from the Soen).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.