HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – UIScreenEdgePanGestureRecognizer无法识别右边缘的手势大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个问题,我已经定义了一个UIScreenEdgePanGestureRecognizer来检测出现在我的设备右边缘的平移手势,但手势是零星识别的:

我有以下代码

_swipeInLeftGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@SELEctor(handleSwipeInFromRightEdge:)];
 _swipeInLeftGestureRecognizer.minimumnumberOfTouches = 1;
 _swipeInLeftGestureRecognizer.maximumnumberOfTouches = 1;
 [_swipeInLeftGestureRecognizer setEdges:UIRectEdgeRight];
 [self.view addGestureRecognizer:_swipeInLeftGestureRecognizer];

- (void)handleSwipeInFromRightEdge:(UIGestureRecognizer*)sender
{
    NSLog(@"swipe from right edge!!!!");
}

手势附加到视图上,没有任何内容.

我错过了什么吗?

解决方法

我设法创建了一个解决方法.这很简单.我已经将uIWindow子类化并使用了touchesBegan / touchesMoved / etc.模拟手势识别的方法.

有用. UIWindow不会自动旋转,因此我必须相应地转换触摸坐标.

这是我的转型版本:

- (CGPoint)transformPoint:(CGPoint)point {
    CGPoint poinTinView = point;

    if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPorTraitUpsideDown) {
        poinTinView.x = self.bounds.size.width - poinTinView.x;
        poinTinView.y = self.bounds.size.height - poinTinView.y;
    } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) {
        CGFloat x = poinTinView.x;
        CGFloat y = poinTinView.y;
        poinTinView = CGPointMake(self.bounds.size.height - y,X);
    } else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) {
        CGFloat x = poinTinView.x;
        CGFloat y = poinTinView.y;
        poinTinView = CGPointMake(y,self.bounds.size.width - X);
    }
    return poinTinView;
}

大佬总结

以上是大佬教程为你收集整理的ios – UIScreenEdgePanGestureRecognizer无法识别右边缘的手势全部内容,希望文章能够帮你解决ios – UIScreenEdgePanGestureRecognizer无法识别右边缘的手势所遇到的程序开发问题。

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

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