UIScrollView programming seems one of the hardest task to me :(
I have subviews in UIScrollView.
I want to let the subviews to take touch event first (and be dragged).
When subviews think it should relinquish touches and scroll should begin, it should be able to tell so to the scrollView.
I've experimented with touchesShouldCancelInContentView but this method only gets called once when scrollView thinks that user actually intended 'scroll'.
I need to take control of when to cancel touch event for subviews not depend on internal uiscrollview's implementation.
My best strategy so far is
subclass ScrollView
- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
SYSLOG(LOG_DEBUG, "MyScrollView touchesBegan");
if (!self.dragging && self.isSubviewTouchable)
[self.nextResponder touchesBegan: touches withEvent:event];
[super touchesBegan: touches withEvent: event];
}
and from subView of scrollView
when subview needs to release the touch and let the scrollView to take touch events so on.
self.myScrollView.isSubviewTouchable = false;
[self touchesEnded: touches withEvent: event];
and in scrollView's delegate class, I set the bool value back.
- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
self.myScrollView.isSubviewTouchable = true;
}
Problem is, calling touchesEnded from the subview doesn't actually release the touch event it seems.(the subview keeps getting dragged even after the touchesEnded call) Also, I don't see scrollView getting any touch event after the touchesEnded call which I hoped it would.
Any ideas?
Thank you