我有一个表视图,它使用来自AFNetworking的延迟加载和占位符图像来显示图像.我正试图在加载时尝试从占位符淡入图像.我的代码在这里工作,但是如果在滚动表格时加载图像,则一切看起来很奇怪,并且表格停止滚动.同样的事情发生在具有相同效果的水平滚动条上.
这是我在cellForRowAtIndexPath中使用的代码
[cell.hotelImage setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:hotelImageUrl]]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
success:^(NSURLRequest *request , NSHTTPURLResponse *response , UIImage *image ){
if (request) {
//Fade animation
[UIView transitionWithView:self.view
duration:1.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[cell.hotelImage setImage:image];
} completion:NULL];
}
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){
}
];
Run Code Online (Sandbox Code Playgroud)
一旦图像在缓存中,我正在使用if(请求)来避免动画.
提前谢谢了.