ios – UIScreenEdgePanGestureRecognizer无法识别右边缘的手势

ios – UIScreenEdgePanGestureRecognizer无法识别右边缘的手势,第1张

概述我有一个问题,我已经定义了一个UIScreenEdgePanGestureRecognizer来检测出现在我的设备右边缘的平移手势,但手势是零星识别的: 我有以下代码: _swipeInLeftGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(hand 我有一个问题,我已经定义了一个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无法识别右边缘的手势所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1054774.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存