【发布时间】:2017-03-22 09:18:13
【问题描述】:
我有一个容器视图,可以在设备为纵向时在其中播放视频。 我希望视频在设备旋转时自动全屏播放。 我试过这段代码来检测设备何时旋转,但它不会将容器更改为全屏
override func willTransition(to newCollection: UITraitCollection, with coordinator: UIViewControllerTransitionCoordinator) {
if (UIDevice.current.orientation.isLandscape) {
videoContainerView.frame = self.view.frame
// self.videoContainerView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height) // this didn't work to....
print("Device is landscape")
}
else{
print("Device is portrait")
}
}
视频在 avplayer 播放器上。 谢谢
【问题讨论】:
-
May by
layoutConstraints可以帮助您解决问题吗?只需将您的videoView绑定到containerView -
他们已经绑定在一起了……
-
我找到了一个解决方案,方法是将 AvplayerController 设置为旋转时的屏幕大小。现在我只需要找到一种方法来关闭导航栏
标签: ios video swift3 autorotate