iosobjective-cuipangesturerecognizeruianimation

Pan Gesture is not recognized for the view while it is being transformed with scale animation? Why this is happening?


[self.currentView addGestureRecognizer:self.pangr]; // added somewhere above in the code

[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.currentView2.transform = CGAffineTransformMakeTranslation(0, self.currentView2.frame.size.height);
self.currentView.transform = CGAffineTransformMakeScale(1.0, 1.0);
} completion:^(BOOL finished) {
self.currentView2 = nil;
}];

Here the currentView does have a pan gesture recognizer and it has a handling function. Inside the handler in the onEnded case i have written the above animation where the currentView2 is dummy one and it is out of concern. the main problem here is after releasing the gesture on the currenView and it is tranforming and during that time the gesture on that view is not recognizing. It is recognizing only after that tranform animation in completed. Why is this happening?

Any explanation will be appriciated. Thank you.

I tried to transform a view and at the same time i want to make the gesture on the view to be recognized. But that is not happening.


Solution

  • User interaction is disabled by default for animated views. Consider adding UIViewAnimationOptionAllowUserInteraction to the list of your options.

    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction animations:^{
    self.currentView2.transform = CGAffineTransformMakeTranslation(0, self.currentView2.frame.size.height);
    self.currentView.transform = CGAffineTransformMakeScale(1.0, 1.0);
    } completion:^(BOOL finished) {
    self.currentView2 = nil;
    }];