marko
marko

Reputation: 1366

Custom UITableViewCell with UIScrollView

Cell doesn't receive touch events, when there is UIScrollView inside UITableViewCell. Is there any way to cancel tap events for UIScrollView (needs only to handle scrolling)?

Upvotes: 0

Views: 1162

Answers (2)

Joe Völker
Joe Völker

Reputation: 791

This is brilliant! I was pulling my hair on this one.

Upvotes: 0

Ethan
Ethan

Reputation: 5805

If you need touches to go through, implement a subclass of UIScrollView, and add these:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{    
    // Pass to parent
    [super touchesBegan:touches withEvent:event];
    [self.nextResponder touchesBegan:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    // Pass to parent
    [super touchesEnded:touches withEvent:event];
    [self.nextResponder touchesEnded:touches withEvent:event];
}

The cell only interecepts taps, so it'll work.

Upvotes: 5

Related Questions