zizoodiesel zizoodiesel - 8 months ago 76
iOS Question

UIPanGestureRecognizer conflict with constraints animation

I have an animation of a contentView of a cell wish have UIPanGestureRecognizer.

the UIPanGestureRecognizer works fine and detect touches but while the animation is happening it doesn't detect touches until it finish the animation.

is there a workaround for this.

this is the animation block

[self.myContentView layoutIfNeeded];
self.contentViewLeftConstraint.constant = -50;
self.contentViewRightConstraint.constant = 50;

[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
[self.myContentView layoutIfNeeded];
} completion:completion];



If you want to allow user interaction during the animation, you must set the option to allow it:

UIViewAnimationOptions options = UIViewAnimationOptionCurveEaseOut |
[UIView animateWithDuration:duration delay:0 options:options animations:^{
    [self.myContentView layoutIfNeeded];
} completion:completion];