Getting the wrong screen resolution for iPad Air
I wrote some code to get the screen resolution as follows.
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
IPAD Air result is similar to the above code.
screenWidth - ------- →> 1024.000000 screenHeight is ------- →> 768.000000
But the actual size is 2048x1536.
Please help me to solve this problem.
Thanks in advance.
+3
source to share
1 answer
This is because of the retinal screen. The actual screen size is presented in points (not pixels). Mesh displays have gotten a higher (2x) pixel density, so you need to multiply by to get the screen size in pixels [UIScreen mainScreen].scale
. This scale factor is equal 1
for normal displays and 2
for the retina.
+3
source to share