当前位置:   article > 正文

设置LaunchScreen.storyboard竖屏显示_storyboard 竖屏

storyboard 竖屏

有时候我们希望App启动页竖屏显示,其它页面既可以竖屏又可以横屏,而在使用LaunchScreen.storyboard作为启动页时,由于LaunchScreen.storyboard无法使用自定义的ViewController,所以也没办法覆盖supportedInterfaceOrientations属性来修改启动页支持的界面方向,这个时候我们可以将Info.plist设置为仅竖屏显示,然后在AppDelegate中设置为支持横竖屏。

    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        return .allButUpsideDown
    }
  • 1
  • 2
  • 3

下面是苹果对该方法的说明,意思是如果未实现此方法,则使用Info.plist里key为supported interface orientations的值作为App支持的界面方向,否则使用该方法返回值作为App支持的界面方向。

- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window;
This method returns the total set of interface orientations supported by the app. When determining whether to rotate a particular view controller, the orientations returned by this method are intersected with the orientations supported by the root view controller or topmost presented view controller. The app and view controller must agree before the rotation is allowed.
If you do not implement this method, the app uses the values in the UIInterfaceOrientation key of the app’s Info.plist as the default interface orientations.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/126305?site
推荐阅读
相关标签
  

闽ICP备14008679号