Not very elegant, but in the absence of any better ideas, here's what's working for me now:
- On the UIScrollView, set
canCancelContentTouches
toYES
anddelaysContentTouches
toNO
. - In the UIScrollViewDelegate, toggle the UIScrollView's subview's
userInteractionEnabled
property when the UIScrollView scrolls:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[_contentView setUserInteractionEnabled:NO];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (!decelerate) {
[_contentView setUserInteractionEnabled:YES];
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
[_contentView setUserInteractionEnabled:YES];
}
- Subclass the UIScrollView and implement:
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
return YES;
}
- Subclass the UIControl and implement
touchesCancelled:withEvent
to reverse whatever theUIControlEventTouchDown
handler does:
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
//custom logic
}