我用下面的代码来处理1个手指轻扫在我的代码:如何处理1到3个手指滑动手势在iOS的
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleViewsSwipe:)];
[swipe setDirection:UISwipeGestureRecognizerDirectionLeft];
[swipe setDelaysTouchesBegan:YES];
[[self view] addGestureRecognizer:swipe];
我知道我可以添加以下行,使其处理2个手指轻扫:
[swipe setNumberOfTouchesRequired:2];
但是当我添加不再检测上面的代码1手指轻扫,因为现在需要触摸的数量是2我能做些什么使我的工作1,2个或3个手指轻扫?
我试过使用下面的代码,但这并没有做我想做的事情。
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleViewsSwipe:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:3];
[panRecognizer setDelaysTouchesBegan:YES];
[[self view] addGestureRecognizer:panRecognizer];
[panRecognizer release];
谢谢。
我添加了上面的代码,但handleViewsSwipe只在触摸为1时触发。如果我尝试使用2个手指或3个手指轻扫,它永远不会被调用。任何想法? – atbebtg 2012-01-29 05:42:52
除了这段代码之外,您还需要做一些rob说的,并在视图中添加3个手势识别器。每个手指数量一个。所有这些都可以参考相同的方法。 – MobileOverlord 2012-01-29 13:20:23
谢谢你的工作! – atbebtg 2012-01-30 03:14:43