AVPlayer UITapGestureRecognizer无法正常工作 [英] AVPlayer UITapGestureRecognizer not working
问题描述
我有 AVPlayerViewController
的代码。
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAvPlayer)];
[self.avPlayerViewController.view addGestureRecognizer:tap];
但这不起作用..:S,我试过设置
but this is not working.. :S, I tried setting
[self.avPlayerViewController.view setUserInteractionEnabled:YES];
仍然不行......
still no good..
唯一可行的解决方案是使用 UIGestureRecognizer
并实现它的 shouldReceiveTouch
委托并检查是否触摸了av播放器..但是问题是,我们不想捕捉tap release事件..因为如果只触及 av player
视图,它会立即执行代码而不是什么我们想要...
The only working solution is to use UIGestureRecognizer
and implement it's shouldReceiveTouch
delegate and check if the av player is touched.. but the issue is, we wan't to capture the "tap release" event.. because if the av player
view is just touched, it immediately executes the code and that is not what we wanted...
请帮我们解决这个问题..
Please help us with this issue..
谢谢!
推荐答案
或者您可以继承AVPlayerViewController并使用folowwing方法
Or you can subclass the AVPlayerViewController and use folowwing method to
获取控件: -
1.touchBegan
2.touchEnd
1.touchBegan 2.touchEnd
确保将此标志设置为self。 avPlayerContr.showsPlaybackControls = false
Make sure that you set this flag self.avPlayerContr.showsPlaybackControls = false
希望这对您有用。
这篇关于AVPlayer UITapGestureRecognizer无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!