在AVPlayerViewController中禁用手势识别器 [英] Disable gesture recognizer in AVPlayerViewController

查看:105
本文介绍了在AVPlayerViewController中禁用手势识别器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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.

推荐答案

我最近偶然发现了一个类似的问题.您可以从AVPlayerViewControllercontentView访问手势识别器.

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中禁用手势识别器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆