When I tap my scrollView it activates a UITapGestureRecognizer that animates the contentOffset for about 2 seconds. How could I allow the user to interrupt the animation and take full control of the scrollView again when they drag? Right now the user has to wait until the end of the animation to start interacting with the scrollView again.

Note: self refers to the scrollView

Tap set up:

let singleTap = UITapGestureRecognizer(target: self, action: "subtleBounce:") singleTap.cancelsTouchesInView = false self.addGestureRecognizer(singleTap)

So when the user taps:

func subtleBounce(gesture : UITapGestureRecognizer) { let originalFrame = self.frame UIView.animateWithDuration(0.1, delay: 0.0, usingSpringWithDamping: 1.5, initialSpringVelocity: 1.5, options: UIViewAnimationOptions.CurveLinear, animations: { self.contentOffset.y -= 10.0 }, completion: { Void in UIView.animateWithDuration(0.6, delay: 0.0, usingSpringWithDamping: 0.1, initialSpringVelocity: 3.0, options: UIViewAnimationOptions.CurveLinear, animations: { self.contentOffset.y += 10.0 }, completion: { Void in }) }) }

So the code above works as intended.

Here is what I've tried to stop the animation and give the user control of the scrollView again:

let drag = UISwipeGestureRecognizer(target: self, action: "stopScrollAnimation:") drag.cancelsTouchesInView = false self.addGestureRecognizer(drag)

and elsewhere:

func stopScrollAnimation(gesture : UISwipeGestureRecognizer) { self.layer.removeAllAnimations() self.setContentOffset(CGPoint(x: 0.0, y: 0.0), animated: false) }

However this DOES NOT work as intended. The animation still controls the scrollView and the user cannot interact with it.

If you want an example what I mean, look at the iOS7/8 lockscreen. After tapping the screen it also starts an animation. The user can take control of the scrollView mid animation however.

edit: accepting answers in swift or obj-c.