How to prevent iphone app from running on non-retina device?

为君一笑 提交于 2020-01-05 07:56:16

问题


I want my app to run on Retina devices only. How do i disable supporting non-Retina iPhone? Is that possible?


回答1:


As the screen size is same for iPhone 3G, 3Gs, 4, 4S; You won't be able to find out which one is retina display among them (AFAIK). But, from iPhone4 the device is having front facing camera, so, You can use that. You can have your App require front-facing camera (Just an example; there are other hardwares too, newly introduced from iPhone4) device capability.

These are specified in the plist file for the app using the UIRequiredDeviceCapabilities key.

A front-facing camera, that would limit it to those devices that have that, eliminating the 3G and 3GS (They are Non-retina displays).

For more details UIRequiredDeviceCapabilities




回答2:


It may work! A hacky way!

You need two images temp.png and temp@2x.png

In your first view controller take a UIButton hidden from view, set background image of it --- temp.png, when your viewDidLoadcalled, that will set the background image for that button, after that, you can check with if([buttonObject currentBackgroundImage] == [UIImage imageNamed:@"temp@2x.png"]) then its a retina support device, you may show some message to user, or do whatever you want to!



来源:https://stackoverflow.com/questions/15779320/how-to-prevent-iphone-app-from-running-on-non-retina-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!