3

I have written code to get the screen resolution like this.

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

The result of IPAD Air is like this for above code.

screenWidth is ------->>> 1024.000000 screenHeight is ------->>> 768.000000

But the actual size is this 2048×1536.

Kindly someone help me out for this problem.

Thanks in advance.

Kiran Kumar
  • 677
  • 3
  • 17
  • 1
    The screen size is reported in points, not pixels. You need to get the scale and multiple by that to get the pixel size of the screen. – zaph May 06 '15 at 10:46

1 Answers1

3

It's because of Retina screen. The actual screen size is presented in points (not pixels). Retina displays got higher (2x) pixels density therefore to get screen's size in pixels you have to multiply it by [UIScreen mainScreen].scale. This scale factor equals 1 for normal displays and 2 for retina.

Artrmz
  • 340
  • 2
  • 14
  • 1
    Kindly explain bit more. Thanks – Kiran Kumar May 06 '15 at 10:51
  • Added some more explanation. – Artrmz May 06 '15 at 10:56
  • 1
    Dear Artrmz, i need to screen resolution as well as CPU of the IPAD to enable functionalities according to that. If you aware kindly let me know. Thanks in advance. – Kiran Kumar May 06 '15 at 10:57
  • What do you need to know about CPU exactly? Here is an answer for how to detect how many cores your device has http://stackoverflow.com/questions/7241936/how-do-i-detect-a-dual-core-cpu-on-ios/7245866#7245866 – Artrmz May 06 '15 at 10:59