0

I have been banging my head against this for a while and I just cannot seem to figure out what is causing this issue.

I have an iPad app that runs only in landscape mode. I need to support both 1024x768 and 2048x1536 resolution screens, and define a viewport and protection for opengl using the device's screen resolution.

This all works fine on 1024x768 devices

However when running on 2048x1536 devices, [UIScreen mainScreen].bounds is still returning 1024x768

I am only targeting iOS 7.0 and later, and I have an asset library set up with launch images. I have even included launch images for portrait mode just to be safe.

I have 4 launch images (which are just white pngs): iPad Portrait iOS 7,8 1x: 768x1024 iPad Portrait iOS 7,8 2x: 1536x2048 iPad Landscape iOS 7,8 1x: 1024x768 iPad Landscape iOS 7,8 2x: 2048x1536

Still, when the application launches, I am getting the wrong screen dimensions, so my OpenGL view only takes up 1/4 of the entire screen

Any help would be GREATLY appreciated

EDIT:

I modified the launch images so I could see which one it is using, and it is using the 2x Landscape image, as expected, but still the returned resolution is incorrect.

1
  • 1
    You also need to take [UIScreen mainScreen].scale into account. For a non-retina device it will be 1.0 and for a retina device it will be 2.0.
    – AdamPro13
    May 4, 2015 at 23:04

2 Answers 2

0

Sizes in iOS are calculated in points. Depending on the device, your scale might be different. [UIScreen mainScreen].scale will return the scale.

Its not recommended that you actually use the resolution of the screen, but instead use the bounds so that the device will automatically render everything with its proper scale.

Furthermore, the iPhone 6 Plus is downscaled, so getting the scale and multiplying the bounds will not give you a proper screen resolution.

0

You can find the correct size by the following line of code.

[[UIScreen mainScreen] currentMode].size;
1
  • This will return the size in pixels. 1024*768 for non retina iPad and 2014*1536 for retina iPad. May 5, 2015 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.