HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 覆盖AVPlayerViewController中的框架手势大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望能够在AVKit中使用新的AVPlayerViewController时更改播放控件的显示方式.基本上,我想覆盖单指点击手势来做其他事情,并用双指点击替换该手势.我是AVPlayerViewController的子类,以添加功能.

我可以通过创建一个新的UITapGestureRecognizer轻松添加双指点击,但只需点击一下就可以做任何事情,因为仍然会出现播放控件并且不会调用我的@L_675_6@手势@L_197_7@.我假设因为AVPlayerViewController有一个优先级被调用的手势.

我像平常那样设置手势……

// singleFingerTap: will never fire...
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@SELEctor(singleFingerTap:)];
singleFingerTap.numberOfTouchesrequired = 1;
singleFingerTap.delegate = self;
[self.view addGestureRecognizer:singleFingerTap];

// doubleFingerTap: will work correctly...
UITapGestureRecognizer *doubleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@SELEctor(doubleFingerTap:)];
doubleFingerTap.numberOfTouchesrequired = 2;
doubleFingerTap.delegate = self;
[self.view addGestureRecognizer:doubleFingerTap];

有关如何在不访问私有财产的情况下实现此目它甚至被允许了吗?我知道我可以使用AVPlayer实例创建自己的视图控制器,然后创建我自己的播放控件,但我希望我可以在这里使用轻量级AVKit播放器进行一些简单的修改.

我已经尝试在AVPlayerViewController的视图中循环播放手势并将其删除,但gestureRecognizers属性为空.即使我能做到这一点,我也不知道如何添加回手势以在双指敲击而不是单指敲击上显示回放控制.

我们欢迎所有的建议!特别是这是否可能/允许.谢谢!

编辑:
我找到了一种@L_197_7@来明确解锁阻止我自己手势的玩家的私人手势.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBerequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    id firstGesture = gestureRecognizer;
    id secondGesture = otherGestureRecognizer;

    if ([firstGesture isKindOfClass:[UITapGestureRecognizer class]] && [secondGesture isKindOfClass:[UITapGestureRecognizer class]]) {
        UITapGestureRecognizer *tapGesture = firstGesture;
        UITapGestureRecognizer *otherTapGesture = secondGesture;

        if (tapGesture.numberOfTapsrequired == otherTapGesture.numberOfTapsrequired && tapGesture.numberOfTouches == otherTapGesture.numberOfTouches) {
        // Disable the single tap that shows the playBACk controls...
            return YES;
        }
    }
    return NO;
}

这有效地防止了回放控件出现在点击上,我的singleTapGesture:按预期触发.但是,我现在遇到的问题是让播放控件出现在不同的手势上.是否可以重新路由私人手势,或以编程方式模拟私人手势?

解决方法

为什么不先检查/修改目标/删除认手势识别器?

您可以使用标准UIView的gestureRecognizers访问它们.

手势识别器可以隐藏在私人子视图内.

另一种解决方案是将userInteractionEnabled设置为NO并将手势识别器添加到superview或“overlay”透明视图.

大佬总结

以上是大佬教程为你收集整理的ios – 覆盖AVPlayerViewController中的框架手势全部内容,希望文章能够帮你解决ios – 覆盖AVPlayerViewController中的框架手势所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。