ios - UIPanGestureRecognizer 与约束动画冲突

标签 ios uipangesturerecognizer

我有一个单元格的 contentView 动画,希望有 UIPanGestureRecognizer。

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

是否有解决方法。

这是动画 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];

谢谢。

最佳答案

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

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

关于ios - UIPanGestureRecognizer 与约束动画冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38675305/

相关文章:

iOS -Urbanairship 生产推送通知无法正常工作

ios - 阻止将手势传递给 SuperView

ios - 为什么在我的 UIPanGestureRecognizer 上调用 UILongPressGestureRecognizer 方法?

ios - 理解[UIView animateWithDuration :completion:]的完成 block

ios - UIPanGestureRecognizer:在滑动结束时检测触摸位置

ios - 使用 UIPanGestureRecognizer 计算轻弹后 UIView 的最终位置

ios - 从第三方 iOS 应用程序打开 Lync 2013 移动客户端

ios - 在加载 View iOS 之前从 Firebase 检索数据

ios - boundingRectWithSize :options:attributes:context: is not returning accurate expected UILabel size

ios - Xcode Instrument 中 SCNNodes 上 SCNAudioPlayer 的持久化