xcode 在 ipad/iphone 上设置不同的启动屏幕界面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27777901/
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
Setup different launch screen interface on ipad/iphone
提问by ShujatAli
I am trying to setup different launch-screen .xib
file in my iPhone application.
我正在尝试.xib
在我的 iPhone 应用程序中设置不同的启动屏幕文件。
I want to know is there any way I can setup different launch screen file in iPad version and iPhone version. Just like Xcode allows different storyboard for iPad/iPhone. I think there must be an option.
我想知道有什么方法可以在 iPad 版本和 iPhone 版本中设置不同的启动屏幕文件。就像 Xcode 允许 iPad/iPhone 不同的故事板一样。我认为必须有一个选择。
Have a look at below screen shot.
看看下面的屏幕截图。
回答by Gosoftworks Development
I created two storyboard files for example: LaunchScreen_iPhone.storyboard and LaunchScreen_iPad.storyboard. Doesn't have to be those exact names. The file names are referenced from the Info.plist file.
我创建了两个故事板文件,例如:LaunchScreen_iPhone.storyboard 和 LaunchScreen_iPad.storyboard。不必是那些确切的名称。文件名是从 Info.plist 文件中引用的。
In the Info.plist file edit the "Launch screen interface file base name" (UILaunchStoryboardName) key value to "LaunchScreen_iPhone"
在 Info.plist 文件中,将“启动屏幕界面文件基本名称”(UILaunchStoryboardName) 键值编辑为“LaunchScreen_iPhone”
Create another key-value entry in the Info.plist in the key name "UILaunchStoryboardName~ipad" and value "LaunchScreen_iPad"
在 Info.plist 中的键名“UILaunchStoryboardName~ipad”和值“LaunchScreen_iPad”中创建另一个键值条目
回答by strangetimes
In the Info.plist file, create another entry called UILaunchStoryboardName~ipad
and set it to your LaunchScreeniPad.xib
在 Info.plist 文件中,创建另一个名为的条目UILaunchStoryboardName~ipad
并将其设置为您的LaunchScreeniPad.xib
回答by oxigen
Create two .xib files named
创建两个名为的 .xib 文件
LaunchScreen2~iphone.xib
LaunchScreen2~iphone.xib
LaunchScreen2~ipad.xib
LaunchScreen2~ipad.xib
回答by Mr. Hedgehog
You can also use storyboard based Launchscreen and make device dependent layout in one file.
您还可以使用基于情节提要的 Launchscreen 并在一个文件中制作依赖于设备的布局。
Layout your launchscreen for iphone with size classes (w: Any, h: Any)
, then change size classes to w: Regular, h: Regular
and layout it again for iPad by uninstalling conflicting views/constraints and installing new.
使用 size classes 为 iphone 布局您的启动屏幕(w: Any, h: Any)
,然后w: Regular, h: Regular
通过卸载冲突的视图/约束并安装新的,将 size classes 更改为并为 iPad 重新布局。
You can read more about adaptive layout here: https://www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started
您可以在此处阅读有关自适应布局的更多信息:https: //www.raywenderlich.com/113768/adaptive-layout-tutorial-in-ios-9-getting-started
I believe this is recommended approach since Apple introduced features like Split View. That way you can launch your app on iPad but with screen size of iPhone.
我相信这是推荐的方法,因为 Apple 引入了 Split View 等功能。这样你就可以在 iPad 上启动你的应用程序,但屏幕大小和 iPhone 一样。