我正在尝试将手势识别器子类化以检测触摸,而不是触摸。 子类化工作正常,只有当我没有把这行放到启用滚动时:
[touchDown requireGestureRecognizerToFail:scroller.panGestureRecognizer];
子类实现:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (self.state == UIGestureRecognizerStatePossible)
{
self.state = UIGestureRecognizerStateRecognized;
}
}
问题是,我需要那行,否则滚动条不会移动..
实施:
TouchDownGestureRecognizer *touchDown = [[TouchDownGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouchDown:)];
[scroller addGestureRecognizer:touchDown];
[touchDown requireGestureRecognizerToFail:scroller.panGestureRecognizer];//not work with it.
答案 0 :(得分:0)
启用滚动条的解决方案:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}