iOS 9:通用应用程序警告“除非应用程序需要全屏,否则必须支持所有界面方向”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37168888/
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
iOS 9 : Warning "All interface orientations must be supported unless the app requires full screen" for universal app
提问by Zaphod
I'm working on an universal app with all orientationson iPad and only portraiton iPhone. The app works well with split-screen multitasking on iOS 9 compatible iPad, but I have this warning:
我正在开发一个在 iPad 上具有所有方向的通用应用程序,在 iPhone上只有纵向。该应用程序适用于兼容 iOS 9 的 iPad 上的分屏多任务处理,但我收到以下警告:
All interface orientations must be supported unless the app requires full screen
And my app does not require full screen. It's only limited to portrait on iPhone... Shouldn't it be ok? Is there a way to declare Requires Full Screenonly on iPhone?
而且我的应用程序不需要全屏。只限于iPhone上的人像……应该没问题吧?有没有办法只在 iPhone 上声明需要全屏?
Thanks in advance
提前致谢
By the way I'm using Xcode 7.3.1
顺便说一下,我使用的是 Xcode 7.3.1
采纳答案by siburb
The solution to this is to use "Device Specific Keys": https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html#//apple_ref/doc/uid/TP40009254-SW9
解决方案是使用“设备特定密钥”:https: //developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html#//apple_ref/doc/uid/TP40009254 -SW9
Your plist values would therefore look something like:
因此,您的 plist 值将类似于:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIRequiresFullScreen~ipad</key>
<false/>
When I remove the iPad specific version of the UIRequiresFullScreen
key, I lose the full split-screen functionality - only "slide over" is available because that doesn't affect my app's use of the full device screen.
当我删除 iPad 特定版本的UIRequiresFullScreen
密钥时,我失去了完整的分屏功能 - 只有“滑过”可用,因为这不会影响我的应用程序对完整设备屏幕的使用。
The "Device Orientation" checkboxes are for the default plist values. The only way they wouldn't affect the app on the iPad is if there's a more specific value in the plist, therefore a value specifically for iPad.
“设备方向”复选框用于默认 plist 值。它们不会影响 iPad 上的应用程序的唯一方法是 plist 中有更具体的值,因此是专门针对 iPad 的值。
When the system searches for a key in your app's Info.plist file, it chooses the key that is most specific to the current device and platform.
当系统在应用程序的 Info.plist 文件中搜索密钥时,它会选择最适合当前设备和平台的密钥。
回答by mital solanki
回答by Zaphod
In fact, it was too easy... That's why I haven't even tried it:
其实也太简单了……这就是我什至没有尝试过的原因:
Setting Portrait
for Device Orientationdoes not impact iPad orientation.
设置Portrait
为设备的方向不会影响iPad的方向。
That means that the Device Orientationsection should be renamed iPhone Orientation, indeed, with that configuration, the iPhone only supports Portrait
and the iPad supports all of them. And the split-screen is still allowed as we have not checked Requires full screen
.
这意味着应该将Device Orientation部分重命名为iPhone Orientation,实际上,使用该配置,iPhone 仅支持Portrait
而 iPad 支持所有这些。由于我们还没有检查,因此仍然允许分屏Requires full screen
。
PS: At least on Xcode 8.3.1, I have not tested it on Xcode 7.x
PS:至少在 Xcode 8.3.1 上,我还没有在 Xcode 7.x 上测试过
回答by tier777
For your case you can use: UISupportedInterfaceOrientations~iphone.
对于您的情况,您可以使用:UISupportedInterfaceOrientations~iphone。
Change UISupportedInterfaceOrientations section in Info.plist to:
将 Info.plist 中的 UISupportedInterfaceOrientations 部分更改为:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~iphone</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
This combination produces no warnings.
这种组合不会产生警告。
回答by OrdoDei
Go to Locations tab from the Preferences, locate project's derived data folder, and delete files related to the project.
从首选项转到位置选项卡,找到项目的派生数据文件夹,并删除与项目相关的文件。