Question

I have a UIScrollView whose 'bounces' property is set to YES. When the contentOffset moves past the top of the screen I show a little animated activity indicator much like the mail program.

It would be nice if at a certain point I could mimic the user lifting the finger - literally cancelling touches in the gestureReconizer and forcing touchesEnded.

In iOS is there a way to interrupt the active touch and cancel it entirely or possibly pass it on to nowhere or to a view that will quietly not respond to it? This is an active UITouch. Most if not all of the ways to do this are set before the finger ever touched the screen. They are not effective in this case.

I looked for ways to directly cancel UITouches, cancelling User interaction entirely, and even tried simply plonking a view directly in the way of the active scrollview, but to no effect.

Is there a way to do this or is it horribly verboten by the Apple gods?

Was it helpful?

Solution

Are you using any custom gesture recognizer or just using the regular scrollview behavior?

One way to cancel a gesture recognizer is to disable and enable it again.

gesture.enabled = NO;
gesture.enables = YES;

If you're using the regular scrollview behavior I would suggest the same approach but going in the userInteractionEnabled property

scrollView.userInteractionEnabled = NO;
scrollView.userInteractionEnabled = YES;

Or maybe:

scrollView.scrollEnabled = NO;
scrollView.scrollEnabled = YES;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top