我有以下代码可以创建四个手势:
self.userInteractionEnabled = YES;
UIPanGestureRecognizer * panGesture = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)];
[panGesture setDelegate:self];
[self addGestureRecognizer:panGesture];
UILongPressGestureRecognizer * longPressGesture = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(handleLongPress:)];
longPressGesture.minimumPressDuration = 0.00;
[self addGestureRecognizer:longPressGesture];
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和LongPress工作正常,但我从来没有得到任何一种Swipe手势。我需要做些什么才能调用滑动选择器?
由于
答案 0 :(得分:1)
我刚回答了这个yesterday。
简短形式:滑动手势是平移手势的特例,默认情况下,两个手势不会同时识别。查看gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
和/或requireGestureRecognizerToFail:
。您可以在Apple's guide中找到有关此问题及相关问题的进一步帮助。