简体   繁体   English

UIScrollView-滚动时检测第二触摸

[英]UIScrollView - detect second touch while scrolling

I have a subclass of UIScrollView that implements this method: 我有一个实现此方法的UIScrollView子类:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
     NSLog(@"touches: %d", [[event allTouches] count]);


    [self.nextResponder touchesBegan:touches withEvent:event];
}

This gets called when I first touch the scroll view. 当我第一次触摸滚动视图时会调用此方法。 However, if I begin dragging the scroll view, then place a second finger down, touchesBegan does not get called. 但是,如果我开始拖动滚动视图,然后再放下第二根手指,touchesBegan不会被调用。 I need to detect when a second touch has occured in the scrollview, even if it is currently scrolling. 我需要检测滚动视图中何时发生第二次触摸,即使当前正在滚动也是如此。 Any ideas? 有任何想法吗?

EDIT: Two touches are registered if I start with two, but if I start with one, begin scrolling, then put a 2nd finger down it is not registered. 编辑:如果我从两个开始,则记录两次触摸,但是如果我从一个开始,则开始滚动,然后将第二根手指放下,则未记录。

Make sure multipleTouchEnabled is set to YES on your scroll view. 确保滚动视图上的multipleTouchEnabled设置为YES

You can also set this in Interface Builder. 您也可以在Interface Builder中进行设置。 Look for 'Multiple Touch' checkbox. 查找“多点触摸”复选框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM