【问题标题】:SafariViewController in Landscape Mode横向模式下的 SafariViewController
【发布时间】:2019-03-08 11:22:59
【问题描述】:

我有一个仅处于纵向模式的 ViewController。它提供了一个 SafariViewController。是否可以将 SafariViewController 的方向更改为横向维护 ViewController 的纵向?

【问题讨论】:

    标签: swift orientation sfsafariviewcontroller


    【解决方案1】:

    这适用于 Swift 4.2。您必须在 viewController 中添加此方法以保持纵向方向

    override var supportedInterfaceOrientations:UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.portrait
    }
    

    你还必须声明

    let appDelegate = UIApplication.shared.delegate as! AppDelegate
    

    您还必须在 AppDelegate 中添加

    var myOrientation: UIInterfaceOrientationMask = .portrait
    
    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        return myOrientation
    }
    

    当你创建 SFSafariViewController 时

    let appDelegate = UIApplication.shared.delegate as! AppDelegate
        appDelegate.myOrientation = .all
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多