3

I have a 1st generation iPad Mini (Model A1432) with a screen resolution of 1024x768 (documentation).

I have the following code in my app:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);

screenSize.height and screenSize.width report: 2048x1536, which is wrong. The screenScale value is 2, but it is my understanding that it should only be 2 for retina screens, which the 1st generation iPad Mini is not.

Any ideas why this might be happening? I'm trying to have code in my app that determines the screen resolution at runtime, as I am doing pixel manipulation for an augmented reality app.

Many thanks for any help.

Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
  • 1
    Are you _sure_ you've got an iPad Mini 1 non-retina? – Rich Apr 27 '14 at 19:46
  • @Rich yes. The model number on the back is [A1432](http://support.apple.com/kb/ht5452#ipad_mini) which corresponds with the WiFi-only 1st generation model (what I have). – Matthew Herbst Apr 27 '14 at 20:18
  • That's weird! Out of interest what does the device name return - if you implement [this method](http://stackoverflow.com/a/11197770/849645)? – Rich Apr 27 '14 at 20:20
  • @Rich That method returns: "iPad2,5" – Matthew Herbst Apr 27 '14 at 20:34
  • Hmm, I was hoping that would return retina (iPad4,4 or iPad4,5) if your device was a bit screwed up! – Rich Apr 27 '14 at 20:39
  • @Rich Do you know where the documentation for the scale value is? I haven't been able to find it. – Matthew Herbst Apr 27 '14 at 20:55
  • 1
    [`@property(nonatomic, readonly) CGFloat scale`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/Reference/UIScreen.html#//apple_ref/occ/instp/UIScreen/scale) – Rich Apr 27 '14 at 20:57
  • Out of interest why do you need the pixel values, you usually just use the points values and let the OS do the rest! (Also I'm going to test this on an iPad mini tomorrow, see if its your device lol) – Rich Apr 27 '14 at 21:02
  • @Rich I'm using [ofTexture of the OpenFrameworks](http://openframeworks.cc/documentation/gl/ofTexture.html#show_draw) library to draw images to the screen. So I make the following call in my draw() method: `tex.draw(0, 0, screenSize.height, screenSize.width);` I can't say I know anything about points - is that the correct way to be doing it instead? – Matthew Herbst Apr 27 '14 at 21:06
  • Its also possible that as the Mini has a high pixel density than the standard iPad, it might be > 1.0 (but not 2.0, more like `163/132 = 1.2ish`), but then I'd expect the Mini retina to also be > 2.0. Also I'd expect it to be mentioned somewhere, but I can't find anything about it! – Rich Apr 27 '14 at 21:07
  • Well for example on iPhone you always know the screen (when in portrait) is going to be 320 points wide, the OS take care of doubling this for retina screens, in the same way that `UIImage` does for `@2x` images. – Rich Apr 27 '14 at 21:09
  • 1
    iPad Mini is 163ppi while the iPad2 is 132ppi (though both have 1024x768 resolution). – Matthew Herbst Apr 27 '14 at 21:10
  • 1
    Ha, I've just had a thought, by any chance are you running an iPhone app on your iPad mini? No a universal one, but a straight up plain iPhone one?! I never thought to check as I assumed it was a iPad app (as you were running it on an iPad!) – Rich Apr 27 '14 at 21:10
  • 1
    Ah! I had the Deployment Info -> Devices set to "Universal" but the little box under it still had iPhone checked instead of the iPad box! #Genius :) – Matthew Herbst Apr 27 '14 at 21:19
  • 1
    Yep, I know the mini at least runs iPhone apps in retina mode! – Rich Apr 27 '14 at 21:21
  • @Rich Write an answer for this so I can give you some credit - I really appreciate your help! – Matthew Herbst Apr 27 '14 at 21:22
  • Glad we got there in the end! :) – Rich Apr 27 '14 at 21:27

1 Answers1

3

After a discussion in comments...!

If you run an iPhone only app on an iPad it will simulate a retina device and report a scale of 2.0. We know (from the above!) that the iPad mini (gen 1) does this as well as the standard iPad 2 running iOS 7 would too.

This was introduced in iOS 7.

Nice gotcha to watch out for!

Rich
  • 8,108
  • 5
  • 46
  • 59