【问题标题】:Force one viewcontroller to be only landscape强制一个视图控制器只为横向
【发布时间】:2016-05-08 16:15:52
【问题描述】:

在我的 swift 项目中,我的所有视图控制器都只能是纵向的,我希望只有 1 个视图控制器是横向的

我的设置here

【问题讨论】:

    标签: ios swift landscape


    【解决方案1】:

    为此,您必须在每个视图控制器中设置纵向和横向的设置以及以下所有代码,除非您需要横向视图

    override func shouldAutorotate() -> Bool {
        return false
    }
    
    override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.Portrait
    }
    

    如需进一步帮助,请查看here

    【讨论】:

    • shouldAutorotate 和supportedInterfaceOrientations 不会被触发:(
    • 我读过一篇文章,我需要添加 UINavigationController 的扩展来覆盖 shouldAutorotate 和supportedInterfaceOrientations,它适用于导航后的第一个视图控制器,但其他没有
    猜你喜欢
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 2013-01-15
    • 1970-01-01
    • 2012-12-09
    • 2011-09-27
    • 1970-01-01
    相关资源
    最近更新 更多