NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.viewchange(_:)), name: UIApplicationDidChangeStatusBarOrientationNotification, object: nil)
界面变化处理函数
- parameter sender: AnyObject
*/
func viewchange(sender:AnyObject){
let orientation = UIApplication.sharedApplication().statusBarOrientation
switch orientation{
case UIInterfaceOrientation.LandscapeRight ,UIInterfaceOrientation.LandscapeLeft:
var video_W = stageWidth
var video_H = stageHeight
if #available(iOS 8.0, *){
video_W = stageWidth
video_H = stageHeight
}else{
video_W = stageHeight
video_H = stageWidth
}
self.videoView.setVideoFrame(CGRect(x: 0, y: 0, width: video_W, height: video_H))
case UIInterfaceOrientation.Portrait:
self.videoView.setVideoFrame(PortraitFrame)
default:
break;
}
}
}