I have a movie view compressed at the right-bottom viewport with portrait mode. And the movie view will expand to full screen in landscape mode when user expand the movie vi
It's caused by this function,
func application(_ application: UIApplication,
supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return shouldRotate ? .allButUpsideDown : .portrait
}
change .allButUpsideDown
to .landscape
will do.
workable code,
AppDelegate.swift
func application(_ application: UIApplication,
supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return shouldRotate ? .landscape : .portrait
}
view controller,
func expandPlayerWindow() {
self.player.view.frame = CGRect(x:0, y:-20, width: UIScreen.main.bounds.maxY, height: UIScreen.main.bounds.maxX)
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")
appDelegate.shouldRotate = true
UIApplication.shared.isStatusBarHidden = true
}