用的UIView和动画完成阻止用户交互 [英] User interaction with uiview and animation completion blocks

查看:170
本文介绍了用的UIView和动画完成阻止用户交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code:

[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
     animations:^{
         imageView.bounds = endBounds;
     }
     completion:^(BOOL finished) {
         [UIView animateWithDuration:2.0 delay:0.5 options:UIViewAnimationOptionAllowUserInteraction
              animations:^{
                  imageView.bounds = startBounds;
              }
              completion:^(BOOL finished) {
                      [imageView removeFromSuperview];
              }];
     }];

此外我有:​​

[imageView setUserInteractionEnabled:YES];

和一个水龙头手势识别组将处理用户敲击ImageView的。虽然第一动画正在发生的事情,对手势识别的火灾,因为我期望的那样。但是,如果我尝试从完成块链式动画过程中自来水ImageView的,即使我已经设置了相应的选项没有任何反应。

and a tap gesture recognizer set that will handle the user tapping on imageView. While the first animation is happening, the gesture recognizer fires as I would expect. But if I try and tap imageView during the chained animation from the completion block, nothing happens even though I have set the appropriate option.

任何人有什么想法?我一派,并不能找到答案。

Anyone have any thoughts? I've googled and can't find an answer.

推荐答案

我想出了一个解决方案:

I came up with a solution:

我用同样的边界/中心点作为形象包装在一个UIView的UIImageView的(我UIView的子类)。然后,我附上手势识别到包装,而不是图像。因为包装的边界矩形/中心点从不为动画的持续时间的变化,它总是可以作为一种姿态的目标。

I wrap the UIImageView in a UIView (I subclass UIView) with the same bounds/center point as the image. Then I attach the gesture recognizer to the wrapper, instead of the image. Because the wrapper's bounds rectangle/center point never change for the duration of the animation, it's always available as the target of a gesture.

这工作得很好。

-j

这篇关于用的UIView和动画完成阻止用户交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆