我在使用 LaunchScreen.storyboard 时遇到了一些问题。
我的应用是通用应用,默认方向是纵向,但也允许横向。
我的 LaunchScreen 非常简单。
具有 2 个约束的 UILabel :
- 对齐通往安全区域(常数 = 30)
- 到安全区的顶部空间(常量 = 30)
当我在具有模拟特征(iPhone XR、iPad、风景、肖像……)的 XCode 中检查我的 LaunchScreen 时,一切看起来都很好。
当我以纵向启动应用程序时,一切看起来正常。
然后我将模拟器(或真实设备)切换为横向并重新运行该应用。
这次 UILabel 不遵守它的约束。标签触及黑色凹口,顶部空间似乎是定义大小的两倍。
你有同样的问题吗?我该如何解决?
最佳答案
Apple 在他们的 documentation 中描述了这一点如下:
At launch time, apps should always set up their interface in a portrait orientation. After the application(_:didFinishLaunchingWithOptions:) method returns, the app uses the view controller rotation mechanism described above to rotate the views to the appropriate orientation prior to showing the window.
所以我相信您所追求的行为恐怕并没有得到 Apple 的特别支持。作为旁注,我不完全确定他们如何在 iPad 上支持它。
关于ios - 通用应用程序 : LaunchScreen not respecting interface builder constraint when launching in landscape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55825509/