xcode 如何将 iOS 应用程序限制为只能使用 4 英寸屏幕设备?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17903577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:38:03  来源:igfitidea点击:

How do I limit an iOS app only to 4 inch screen devices?

iosxcode

提问by Kyle

Is there a setting in Xcode that lets me declare that my app only supports 4" screen devices (iPhone 5 and the newest iPod Touch)?

Xcode 中是否有设置可以让我声明我的应用程序仅支持 4" 屏幕设备(iPhone 5 和最新的 iPod Touch)?

回答by Undo

Nope.

不。

Because iOS 7 supports devices with 3.5" screens, you can't use the only-support-iOS-x technique.

因为 iOS 7 支持 3.5" 屏幕的设备,所以你不能使用 only-support-iOS-x 技术。

Also, there isn't a setting in Xcode or a key for requiredDeviceCapabilitieswhich allows you to make the app 4-inch only.

此外,Xcode 中没有设置或requiredDeviceCapabilities允许您将应用程序设置为仅 4 英寸的键。

回答by Sr.iOSDev

As you can see in below screenshot which is taken from Apple's official website, iPhone 4 and iPhone 4s are the ones with 3.5 inch screen and they do support iOS 7.

正如你在下面的苹果官网截图中看到的,iPhone 4 和 iPhone 4s 是 3.5 英寸屏幕,它们确实支持 iOS 7。

enter image description here

在此处输入图片说明

So you cannot constrain the app resolution support for 4 inch screen only by even using iOS 7.

因此,即使使用 iOS 7,您也无法限制对 4 英寸屏幕的应用分辨率支持。

Also as per the below forum there is no way we can just put application on app store that only supports 4 inch screen iPhone.

同样根据下面的论坛,我们无法将应用程序放在仅支持 4 英寸屏幕 iPhone 的应用程序商店中。

iPhone app for 4-inch screen only?

仅适用于 4 英寸屏幕的 iPhone 应用程序?

Let me know if you need more help.

如果您需要更多帮助,请告诉我。

回答by Mengli

Yes. You may not be able to add a setting in Xcode or a key for requiredDeviceCapabilities which allows you to make the app 4-inch only. But you can allow the user launch the application first, then in the very beginning view controller detect screen size by using following code:

是的。您可能无法在 Xcode 中添加设置或 requiredDeviceCapabilities 的键,这使您只能将应用程序设为 4 英寸。但是您可以允许用户先启动应用程序,然后在最开始的视图控制器中使用以下代码检测屏幕大小:

CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;

Last, based on the device screen size you preferred to run your app, you can either disable the next activity or continue.

最后,根据您希望运行应用程序的设备屏幕尺寸,您可以禁用下一个活动或继续。