我正在尝试在选择表格 View 单元格时制作一些动画。出于某种原因,完成 block 被调用得太早了。即使将持续时间设置为 10 秒,完成 block 也会立即被调用。
[UIView animateWithDuration:10.0 animations:^{
message.frame = newFrame;
} completion:^(BOOL finished) {
NSLog(@"DONE???");
}];
有没有想过为什么会这样?谢谢。
最佳答案
completion
A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.
这意味着不能保证代码只会在动画完成时执行。我建议您检查“完成”参数作为执行条件。
关于iOS - UIView animateWithDuration 中的完成 block 被过早调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14669601/