【发布时间】:2013-03-11 04:10:42
【问题描述】:
我创建了自定义tableView 并在其他类中使用自定义tableView 类来显示tableView..
我正在从服务器加载图像并将其显示在tableViewRow.. 每个image 中都不同..
在屏幕上,10 张图像中只有 7 张会出现,当我向下滚动时,前 3 张图像会重复一段时间,当这些图像加载时,它会显示正确的图像.. 但最初直到新图像出现,它才会显示旧图像图像,我想放置一个活动指示器来显示图像正在加载而不是旧图像..
我想在image 的位置添加activity Indicator,直到image 加载..
我的代码是...
self.tableViewX = tableView;
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView1 dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
NSString *imageURL = [NSString stringWithFormat: @"www.xyz.image.png"];
cell.thumbnailImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]];
});
请帮助我提供一些示例代码..
【问题讨论】:
-
您可以使用异步图像视图来实现这一点。因为图像显示是这样的,因为您使用的是 dequeueReusableCellWithIdentifier 所以制作一个不同的标识符或使单元格为零..然后你可以实现它跨度>
-
@08442 : 如何使用异步图像视图?你有任何我可以理解的示例代码吗..
-
@bhargavi:我们需要 ASIHTTPRequest 类来执行此操作吗?
-
我不能创建图像的子视图,以便活动指示器在图像加载之前一直工作吗?
标签: ios objective-c objective-c-blocks uiactivityindicatorview