1

I've just restarted work on a project I last worked on 4 years ago. Back then, I was using Xcode 3.2 and an iPad 2. Now I am on Xcode 8.1 and an iPad Air 2.

I can build and run the project just fine with Xcode 8.1 but there is something strange going on when getting the screen size using

CGRect rect = [[UIScreen mainScreen] bounds];

It returns 768x1024 pixels on my iPad Air 2 which can't be true because the iPad Air 2's native resolution is 1536x2048. 768x1024 is the resolution of the iPad 2, my old device.

Furthermore, not only does bounds return the wrong dimensions, I can also clearly see that the graphics I draw to my view have been upscaled.

So my assumption is that my project is running in some sort of legacy/compatibility mode that tries to make the app believe it is still running on an iPad 2 in a resolution of 768x1024 instead of a resolution twice as big. Could that be the case or what is the explanation for this phenomenon?

So how can I get this to work correctly? i.e. how can I get bounds to return 1536x2048 and stop automatic upscaling? I have already looked through the various options in Xcode but I don't see anything that could explain the behaviour I'm seeing here. My deployment target is set to iOS 10.1 so I don't really see why my app is put in this strange legacy mode or whatever it is...

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Andreas
  • 9,245
  • 9
  • 49
  • 97
  • 1
    *"It returns 768x1024 pixels"* - No, it returns 768x1024 **points**. Please read the documentation for the `UIScreen bounds` property. – rmaddy Nov 20 '16 at 19:14

1 Answers1

1

You are confused here you are getting correct bounds from here

CGRect rect = [[UIScreen mainScreen] bounds];

1536x2048 is the resolution of iPad Air 2 not its screen size i.e. iPad Air 2 is supporting @2x resolution.

If you will check bounds of iPad Air 2 then you will get 768x1024

Rajat
  • 10,977
  • 3
  • 38
  • 55
  • 1
    It's a common confusion of pixels vs points. Here's another stackoverflow link that covers this in more detail. http://stackoverflow.com/questions/12019170/what-is-pixel-and-points-in-iphone – xdeleon Nov 20 '16 at 15:51