2

I need to know current device is iPad2 or new iPad. I use [[UIScreen mainScreen] Scale],but the result is 1.0

Rafał Rawicki
  • 21,626
  • 3
  • 57
  • 77
spmno
  • 685
  • 6
  • 12
  • 2
    possible duplicate of [Programmatically detect an iPad 3 (HD)?](http://stackoverflow.com/questions/9688930/programmatically-detect-an-ipad-3-hd) – Rafał Rawicki Apr 12 '12 at 07:17
  • 1
    build your app with xcode 4.3 with 5.1 SDK - this way you should get scale 2.0 for iPad3 – Rok Jarc Apr 12 '12 at 08:07

1 Answers1

5

As found here:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && [[UIScreen mainScreen]     respondsToSelector:@selector(scale)] && [UIScreen mainScreen].scale > 1)
{
    // new iPad
}
Community
  • 1
  • 1
BluesRockAddict
  • 15,177
  • 3
  • 34
  • 34
  • this method is not effective. new ipad scale also 1. and thank you your answer. – spmno Apr 12 '12 at 07:17
  • 1
    the new ipad scale is 2.0. You don't need to check for `respondsToSelector` since he's looking at iPad 2 and the new iPad, which means it always have `scale` property – jasondinh Apr 12 '12 at 07:41
  • @spmno - I can confirm that the `scale` property returns 2.0 on the new iPad in all of my applications, so it is a viable check. Note that you need to be building with the iOS 5.1 SDK for this to work. – Brad Larson Apr 16 '12 at 15:46