gpt4 book ai didi

iphone - 动画 block 相互干扰

转载 作者:行者123 更新时间:2023-11-28 23:05:08 28 4
gpt4 key购买 nike

我基本上是在运行两个动画,一个接一个,它们似乎相互干扰或以某种方式干扰 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];
}];

一旦该 block 完成,它就会运行 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 掩码添加到选项参数

[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 - 动画 block 相互干扰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9441960/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com