1

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?

NFG
  • 639
  • 1
  • 5
  • 15

1 Answers1

1

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;
manecosta
  • 8,682
  • 3
  • 26
  • 39
  • From the tests I have performed these properties all need to be set before the touch begins. What I am learning now is that I am on the wrong path to enlightenment, and I need to subclass:http://stackoverflow.com/questions/1685956/uiscrollview-touchesbegan/17759373#17759373 – NFG Feb 11 '14 at 20:44
  • No, if you disable the gesture, scrolling or interaction during the touch and enable it back again, the touch will be canceled. – manecosta Feb 11 '14 at 20:46
  • So, I did not test diabling the gesture itself, but I did test the two methods on the scroll view. scrollView.userInteractionEnabled = NO did not interrupt the interaction, but once the touch was over I could not scroll the scrollview. On the other hand swtiching off scrollEnabled shut the business down, and I did this: – NFG Feb 11 '14 at 21:19
  • `CGPoint SlideOffset = verticalSlide.contentOffset; verticalSlide.scrollEnabled = NO; verticalSlide.contentOffset = SlideOffset; [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:(void (^)(void)) ^{ verticalSlide.contentOffset = CGPointZero;} completion:^(BOOL finished){ verticalSlide.scrollEnabled = YES;}];` – NFG Feb 11 '14 at 21:19