0
votes

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.

2
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

2 Answers

0
votes

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
votes

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

[[UIScreen mainScreen] currentMode].size;