【发布时间】:2012-03-28 12:39:26
【问题描述】:
我有一个 UIIMageView 子类,我正在添加一个 UIPanGestureRecognizer 和一个 UISwipeGestureRecognizer,如下所示:
self.userInteractionEnabled = YES;
UIPanGestureRecognizer * panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[self addGestureRecognizer:panGesture];
UISwipeGestureRecognizer * swipeUp = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeUp:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
[self addGestureRecognizer:swipeUp];
UISwipeGestureRecognizer * swipeDown = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeDown:)];
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
[self addGestureRecognizer:swipeDown];
但是当我向上或向下滑动时,我的选择器不会被调用,但 pan 总是如此。
任何澄清都会有所帮助。
谢谢
【问题讨论】:
-
尝试使用 panGesture 的这个属性 "minimumNumberOfTouches" 为了识别这个手势,可以触摸视图的最小手指数。将其设置为 2 并检查是否识别滑动?
-
是的,这行得通,但是我需要两根手指来做我的平底锅,所以这并不是我真正需要的。
标签: iphone objective-c xcode ipad