UIPanGestureRecognizer与约束动画冲突

时间:2016-07-30 15:00:07

标签: ios uipangesturerecognizer

我有一个想要有UIPanGestureRecognizer的单元格内容视图的动画。

UIPanGestureRecognizer可以正常工作并检测触摸,但在动画发生时,它不会检测到触摸,直到完成动画。

是否有针对此的解决方法。

这是动画块

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

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

感谢。

1 个答案:

答案 0 :(得分:3)

如果要在动画期间允许用户交互,则必须设置允许它的选项:

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