我正在尝试使用 3rd 方库下载文件AFNetworking
,其核心是NSOperation
一个可以设置完成块的对象,用于下载完成时。
不知何故,animateWithDuration:
这个块内的一个不能正常运行:它的完成块和实际动画都延迟了大约 5 或 60 秒,或者根本不运行。知道它完全启动的唯一方法是通过 NSLog 调用。
让我演示一下:
[UIView animateWithDuration:0.1
animations:^{
controller.view.alpha=0.5;
NSLog(@"First Try Start");
}
completion:^(BOOL finished) {
NSLog(@"First Try End");
}];
// Here comes the NSOperation completion block
[self->currentConnection setCompletionBlock:^{
NSLog(@"downloadComplete!");
[UIView animateWithDuration:0.1
animations:^{
controller.view.alpha=0.5; // this doesn't run immediately, only the NSLog line
NSLog(@"Second Try Start");
}
completion:^(BOOL finished) {
NSLog(@"Second Try End");
}];
}];
控制台输出:
2013-06-28 23:22:11.374 ML[7831:c07] First Try Start
2013-06-28 23:22:11.477 ML[7831:c07] First Try End
2013-06-28 23:22:11.742 ML[7831:1303] downloadComplete!
2013-06-28 23:22:11.745 ML[7831:1303] Second Try Start
2013-06-28 23:23:05.007 ML[7831:c07] Second Try End
帮助表示赞赏!