0xdeadfa11
0xdeadfa11

Reputation: 63

How to Stop a UIScrollView from Swallowing Touches

I have UIScrollView that has many subviews. When I scroll, I want to tap on a subview which I want to be dragged. Is there a possible way to make the UIScrollView stop from swallowing touches? Or is it possible to start new touch when you cancel the scrolling (like what it scrolls and I tapped on it, the subview will be tapped as well so I can drag it out)?

Upvotes: 1

Views: 4371

Answers (1)

matzahboy
matzahboy

Reputation: 3024

Subclass UIScrollView and override the - (BOOL)touchesShouldCancelInContentView:(UIView *)view method. Here's an example to allow uibutton touches to pass through:

#import "scrollViewWithButtons.h"

@implementation scrollViewWithButtons

- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
    return ![view isKindOfClass:[UISlider class]];
}

@end

Upvotes: 2

Related Questions