简体   繁体   中英

UIScrollView - detect second touch while scrolling

I have a subclass of UIScrollView that implements this method:

-(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. 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.

You can also set this in Interface Builder. Look for 'Multiple Touch' checkbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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