我在风景式上玩维多。当设备方向发生变化时,视图只在landscapeLeft和landscapeRight之间旋转。也就是说,在播放电影时没有肖像模式。此外,除了电影视图,其他视图都是描绘模式,所以应用程序配置是纵向的。如何使电影视图只在景观模式中旋转。
这是我代码的一部分。
申请代表,
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")目前的问题是,当方向发生变化时,电影视图可以是原型。
发布于 2017-05-10 02:47:18
将.allButUpsideDown更改为.landscape
func application(_ application: UIApplication,
supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return shouldRotate ? .landscape : .portrait
}https://stackoverflow.com/questions/43752132
复制相似问题