首页 文章

仅在landscapeLeft和landscapeRight之间旋转

提问于
浏览
0

我有vidoe在横向模式下玩 . 当设备方向改变时,视图仅在landscapeLeft和landscapeRight之间旋转 . 也就是说播放电影时没有肖像模式 . 除了电影视图之外,其他视图都是portraint模式,因此app配置是纵向的 . 如何使影片视图仅在横向模式下旋转 .

这是我的代码的一部分 .

的appdelegate,

internal var shouldRotate = false

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

电影视图控制器,

let appDelegate = UIApplication.shared.delegate as! AppDelegate
    appDelegate.shouldRotate = true // or false to disable rotation
    let value = UIInterfaceOrientation.landscapeLeft.rawValue
    UIDevice.current.setValue(value, forKey: "orientation")

目前的问题是,当方向改变时,电影视图可以是protrait .

1 回答

  • 0

    .allButUpsideDown 更改为 .landscape

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

相关问题