动画块互相干扰

时间:2012-02-25 06:43:30

标签: iphone ios xcode ipad

我基本上是一个接一个地运行两个动画,似乎他们正在以某种方式干扰彼此或UIView。我的代码在5.0模拟器上完美运行,但在4.3模拟器中遇到问题。

基本上我在屏幕上有一堆图像。触摸对象时,它会缩小尺寸:

[UIView animateWithDuration:0.1f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^(void) {
                         //resizing the frame to make it bigger (original size is the new bigger size)
                         self.frame = CGRectMake(point.x - originalSize.width/2, point.y - originalSize.height/2 , originalSize.width, originalSize.height);

                     }
                     completion:^(BOOL complete){
                         //I have a showArrow method that draws an arrow to the superview to show the user where to place their image
                         [self performSelector:@selector(showArrow) withObject:nil afterDelay:1];
                     }];

一旦该块完成,它就会运行showArrow,它只显示一个弹跳箭头:

[UIView animateWithDuration:0.5f
                          delay:0.0f
                        options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat
                     animations:^(void) {
                         self.arrow.frame = CGRectMake(arrowOrigin.origin.x, arrowOrigin.origin.y - 200, arrow.frame.size.width, arrow.frame.size.height);
                         self.arrow.alpha = 0.5;
                     }
                     completion:NULL];

正如我所提到的,这在我的iPad和5.0模拟器上完美运行,但在4.3中,一旦第一个动画运行,它似乎会冻结图像的平移手势或触摸的能力。有什么想法吗?感谢

1 个答案:

答案 0 :(得分:2)

尝试将UIViewAnimationOptionAllowUserInteraction掩码添加到选项参数

[UIView animateWithDuration:0.1f
                      delay:0.0f
                    options:UIViewAnimationOptionCurveEaseIn |
                            UIViewAnimationOptionAllowUserInteraction
                 animations:^(void) {
                 // ...

showArrow

[UIView animateWithDuration:0.5f
                      delay:0.0f
                    options:UIViewAnimationOptionAutoreverse |
                            UIViewAnimationOptionRepeat |
                            UIViewAnimationOptionAllowUserInteraction
                 animations:^(void) {
                 // ...