【问题标题】:how to change orientation of viewController that is not in storyboard如何更改不在情节提要中的viewController的方向
【发布时间】:2017-02-02 04:20:15
【问题描述】:

在下面的示例中,有一种方法可以使 readerVC 的方向为纵向和横向。

func loadReader(filePaht : String)  {

            let document = ReaderDocument(filePath: filePaht, password: nil)
            if document != nil {
                let readerVC = ReaderViewController(readerDocument: document)
                readerVC?.delegate = self
                readerVC?.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
                readerVC?.modalPresentationStyle = UIModalPresentationStyle.fullScreen
                self.navigationController?.pushViewController(readerVC!, animated: true)

                UIApplication.shared.isStatusBarHidden = true
            }
        }

【问题讨论】:

    标签: ios swift screen-orientation uiinterfaceorientation


    【解决方案1】:

    您可以覆盖支持的界面方向:

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .all
    }
    

    或者您可以return .allButUpsideDownreturn .portrait - 任何您想指定的内容。

    【讨论】:

      猜你喜欢
      • 2016-04-02
      • 2012-02-09
      • 1970-01-01
      • 2018-10-09
      • 2020-06-02
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 2015-03-19
      相关资源
      最近更新 更多