检测iPhone应用程序的iPad 2x按钮

mad*_*ik3 6 iphone ipad

有没有办法检测到你的iPhone应用程序我们在iPad上运行2x/1x?

我需要能够检测到我的应用程序每英寸点数的差异.

mag*_*gma 6

检查scale财产:

[[UIScreen mainScreen] scale]
Run Code Online (Sandbox Code Playgroud)

这是一个方便的功能:

+(BOOL) screenIs2xResolution {
  return 2.0 == [MyDeviceClass mainScreenScale];
}

+(CGFloat) mainScreenScale {
  CGFloat scale = 1.0;
  UIScreen* screen = [UIScreen mainScreen];
  if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
    scale = [screen scale];
   }
  return scale;
}
Run Code Online (Sandbox Code Playgroud)

致谢:http://www.markj.net/iphone-4-2x-graphics-scale-ipad/

另见:http://struct.ca/2010/high-res-graphics-in-cocos2d/


que*_*ish 0

您可以通过注册通知来检测更改_UIClassicApplicationWillChangeZoomNotificationName,然后或多或少使用 @magma 在他的答案中概述的方法来处理比例更改。_UIClassicApplicationWillChangeZoomNotificationName当使用“2x”/“1x”按钮更改比例时,会告诉您。