嗨,在我的应用程序中,我正在使用AvplayerViewcontroller并在双击时想要显示程序详细信息时在AvplayerViewcontroller.view上添加轻击手势。我可以显示,但视频正在缩放。我不要那种变焦效果。为了禁用此功能,我什至尝试通过禁用avplayer的userInteraction进行尝试,但是那时即使手势也没有采取用户操作(轻击)。请指导我如何解决此问题。
最佳答案
更新:@NareshGadamsetty结帐。
如果showsPlaybackControls=false
,则只需将UITapGestureRecognizer
添加到contentOverlayView
class MyPlayerViewController: AVPlayerViewController, UIGestureRecognizerDelegate {
func addPlayer()
...
...
showsPlaybackControls=false
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(showDetail))
tapGesture.numberOfTapsRequired = 2
contentOverlayView?.addGestureRecognizer(tapGesture)
}
func showDetail() {
// Do whatever you want to do in this method
}
}
否则执行
UIGestureRecognizerDelegate
class MyPlayerViewController: AVPlayerViewController, UIGestureRecognizerDelegate {
func addPlayer()
...
...
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
if touch.tapCount == 2 {
showDetail()
return false
}
return true
}
private func showDetail() {
// Do whatever you want to do in this method
}
}
关于ios - 双击iOS时禁用AV Player中的缩放效果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51965294/