【问题标题】:How to rotate orientation?如何旋转方向?
【发布时间】:2018-03-31 21:55:22
【问题描述】:

当我从纵向模式下的UINavigationController 切换到UIViewController 到横向模式时,我想旋转方向,但它不起作用。

我试过了

(UIApplication.shared.delegate as! AppDelegate).window!.rootViewController = playModeVc

但我可以纵向看到下一个 viewController,但我想在横向模式下看到它。当我使用

present(playModeVc, animated: true, completion: nil)

它不会释放内存。

我想在切换 viewController 时释放内存。我该怎么做?

【问题讨论】:

    标签: ios swift uinavigationcontroller viewcontroller


    【解决方案1】:

    我从您的问题中了解到,您希望强制一个视图控制器始终以横向模式显示。

    这是在 Swift 3 中的操作方法。将此代码添加到您希望以横向显示的视图控制器:

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {  
        return UIInterfaceOrientationMask.landscape  
    }  
    
    override var shouldAutorotate: Bool {  
        return false  
    } 
    

    【讨论】:

    • 我做到了,但它不起作用...我有 4 个纵向模式的 ViewController,但我需要一个横向模式的控制器...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 2015-12-27
    • 1970-01-01
    相关资源
    最近更新 更多