我是新来学习目标-c。我想在显示来自服务器的图片时向每个UIActivity
添加UITableViewCell
指标,并在finishedloading.
请帮我提供一些示例代码。
非常感谢。
答案 0 :(得分:1)
您可以在图像视图中添加活动指示器,并在图像从服务器开始加载时开始动画,当您从服务器获得实际图像时停止动画。请尝试以下代码
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.center = imageView.center;// it will display in center of image view
[iamgeView addSubview:indicator];
[indicator startAnimating]
有图像时请致电[indicator stopAnimating]
。
在表格视图单元格中放置动画: //你设置placehod更好
[imageView setImageWithURL:[NSURL URLWithString:imageURL]
placeholderImage:[UIImage imageNamed:@"if any "]
success:^(UIImage *image) {
// remove animation
[indicator stopAnimating];
[indicator removeFromSuperview];
}
failure:^(NSError *error) {
// handle failed download
}];
答案 1 :(得分:1)
请参阅以下链接
https://developer.apple.com/library/ios/samplecode/LazyTableImages/Introduction/Intro.html
https://github.com/rs/SDWebImage
Lazy Load cell image for programmatically created tableview
http://www.markj.net/iphone-asynchronous-table-image/
http://www.hollance.com/2011/03/mhlazytableimages-efficiently-load-images-for-large-tables/#!