我有一个UITableViewController,用一些我从网上下载的数据填充UITableView.每个单元格的数据也包含一个用作背景的图像,我在一个单独的NSOperation中下载,添加到NSOperationQueue中,MaxConcurrentOperationCount设置为4.只要图像没有下载,我就会显示一个通用占位符想要在下载的图像成功下载后替换(淡出/淡入).
我正在使用cellForRowAtIndexPathUITableViewController中的以下代码.
[UIView beginAnimations:@"fade" context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:3.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
cell.placeholderUIImage.alpha = 0.0;
cell.backgroundUIImage.alpha = 1.0;
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
不幸的是,这只是随机工作几行,因为最多的是背景图像立即被设置,好像在一个单元格上开始的动画将被下一次调用"覆盖" beginAnimations.