当我点击 UIButton
时,比如 b1
,会生成两个随机值,x
和 y
它成为另一个 UIButton
的新坐标,比如 b2
。 b2
慢慢移动到所需位置(使用 +[UIView animateWithDuration: animations:]
)。现在我想要发生的是:当 b2
处于运动状态时,再次单击 b1
应该将 b2
移动到新坐标。现在发生的情况是,在 b2
很好地固定在生成的位置之前,我无法单击 b1
。有什么见解吗?
最佳答案
你会想要使用
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
相反。并在选项中设置 UIViewAnimationOptionAllowUserInteraction
,以便 iOS 在动画发生时不会阻止用户交互。
您还需要设置 UIViewAnimationOptionBeginFromCurrentState
以便按钮从当前状态开始。
关于objective-c - 当一个 Action 已经在进行时,用一个按钮开始一个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6415849/