我基本上在运行两个动画,一个接一个,似乎它们在相互干扰或以某种方式干扰UIView。我的代码在5.0 Simulator上运行良好,但在4.3 Simulator中出现问题。
基本上,我在屏幕上有一堆图像。触摸对象时,它会按比例放大:
[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中,一旦第一个动画运行,它似乎冻结了图像的平移手势或被触摸的能力。有什么想法吗?谢谢
最佳答案
尝试将UIViewAnimationOptionAllowUserInteraction
掩码添加到options参数
[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) {
// ...
关于iphone - 动画块相互干扰,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9441960/