Kiran Kumar
Kiran Kumar

Reputation: 677

Getting incorrect screen resolution for IPAD Air

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.

Upvotes: 3

Views: 599

Answers (1)

artur-dev
artur-dev

Reputation: 350

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.

Upvotes: 3

Related Questions