iOS禁用Landscape LaunchScreen.storyboard [英] iOS Disabling Landscape LaunchScreen.storyboard

查看:348
本文介绍了iOS禁用Landscape LaunchScreen.storyboard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示徽标的LaunchScreen.storybaord(文字,因此与方向无关).该应用程序始终以纵向启动,但它具有某些允许横向模式的视图控制器(因此,不可以仅使应用程序为纵向).

I have an LaunchScreen.storybaord that shows a logo (textual so it is orientation agnostic). The app starts always in portrait, but it has certain view controllers that allow landscape mode (so making the app portrait only is not an option).

我想要的是启动屏幕始终显示为纵向.因此,在应用启动过程中将手机保持在横向模式下应该会导致徽标旋转(就像在查看不支持横向模式的视图控制器一样)

What I want is that the launch screen always comes up in portrait. So holding the phone in landscape during app start should result in seeing the logo rotated (as if looking at a view controller that does not support landscape)

有没有办法让分镜脚本只能是纵向的?

Is there a way to tell the storyboard to be portrait only?

我尝试使用大小类特征,但是这种方式只能解决左或右横向问题.由于还为首次用户提供了一个启动屏幕的徽标屏幕,因此徽标的旋转取决于手机在横向放置的方向.

I tried to use size classes traits, but this way I can only address left OR right landscape. Since there is also an intro screen for first time users that animate the logo from launch screen, the logo rotation depends on which direction the phone was put in landscape.

推荐答案

有几种方法可以实现此目的.不过,我的首选方法是在Info.plist

There are several approaches to achieve this. My preferred one though is to specify in Info.plist

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>

在应用程序在AppDelegate中完成启动后,将其覆盖

And override this after app finished launching inside AppDelegate

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    return [.allButUpsideDown]
}

来源: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆