问题描述
在AVPlayerViewController
中,有一个功能可以停止播放视频并通过滑动视图来关闭AVPlayerViewController
.
In AVPlayerViewController
there is a feature for stopping the playback of a video and closing the AVPlayerViewController
by swiping its view.
我想禁用此功能.我想我需要禁用手势识别器!?
I want to disable this feature. I guess I need to disable a gesture recognizer!?
但是我不知道如何为玩家做这件事.
But I don’t know how to do this for the player.
推荐答案
我最近偶然发现了一个类似的问题.您可以从AVPlayerViewController
的contentView
访问手势识别器.
I recently stumbled upon a similar problem. You can access the gesture recognizers from the contentView
of AVPlayerViewController
.
如果只想保留点击手势识别器,则可能需要使用如下功能:
If you wanted to keep only the tap gesture recognizer, you might want to use a function like this:
extension AVPlayerViewController {
func disableGestureRecognition() {
let contentView = view.value(forKey: "contentView") as? UIView
contentView?.gestureRecognizers = contentView?.gestureRecognizers?.filter { $0 is UITapGestureRecognizer }
}
}
这篇关于在AVPlayerViewController中禁用手势识别器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!