rya*_*yan 26 uiviewanimation ios
我正在尝试在选择表视图单元格时执行一些动画.出于某种原因,完成块过早被调用.即使将持续时间设置为10秒,也会立即调用完成块.
[UIView animateWithDuration:10.0 animations:^{
message.frame = newFrame;
} completion:^(BOOL finished) {
NSLog(@"DONE???");
}];
Run Code Online (Sandbox Code Playgroud)
有关为什么会发生这种情况的任何想法?谢谢.
Joh*_*rck 17
是.它被称为太早,因为它被某种方式打断了.可能是通过模态演示过渡或者其他东西.根据您的需要,以下可能是您喜欢的解决方案.我们通过手动延迟动画代码的执行来避免冲突,如下所示:
// To get this in Xcode very easily start typing, "dispatch_aft..."
// Note the "0.2". This ensures the outstanding animation gets completed before we start ours
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:1.0 delay:0 options:0 animations:^{
// Your animation code
} completion:^(BOOL finished) {
// Your completion code
}];
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18902 次 |
| 最近记录: |