问题描述
我创建了自定义 tableView
并在其他类中使用自定义 tableView
类来显示 tableView
..
I have created the Custom tableView
and using custom tableView
class in Other class to Show the tableView
..
我从服务器加载图像并将其显示在 tableViewRow ..每个
图片
与...不同..
I am Loading the image from Server and displaying it in the
tableViewRow
.. each image
is different in it..
在屏幕上只有7个图像中的7个将会来,当我向下滚动前3个图像重复一段时间,当这些图像加载它显示正确的图像..但最初,直到新图像将显示旧图像,我想要一个活动指示器来显示图片正在加载而不是旧图片..
On Screen only 7 out of 10 images will come, and when I scroll down the first 3 images are repeating for some time and when those images get load its showing proper images.. but initially till new images will come its showing old images, I want to put a activity indicator to show that the images are loading instead of old images..
我想在<$的位置添加
,直到活动指标
c $ c> image 图片
获取加载..
I want to add activity Indicator
in the place of image
, till the image
get load..
我的代码是...
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]]];
});
请帮我提供一些示例代码..
Please assist me with some sample code..
推荐答案
您可以使用AsyncImageView类文件同步加载图像,并在图片加载时显示活动指示
You can use "AsyncImageView" class files it will load image synchronically and it shows the activity indicator while image loading
您可以从以下链接下载AsyncImageView类文件: -
You can download "AsyncImageView" class files from following link:-https://www.dropbox.com/s/peazwjvky9fsjd7/Archive.zip
在.m文件中导入AsyncImageView类
in .m file import AsyncImageView Class
#import "AsyncImageView.h"
in indexpath方法中的tableview单元格
in your tableview cell at indexpath method
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
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];
}
NSString *imageURL = [NSString stringWithFormat: @"www.xyz.image.png"];
AsyncImageView *async = [[AsyncImageView alloc]initWithFrame:CGRectMake(0, 0, width, height)];
[async loadImageFromURL:[NSURL URLWithString:imageURL]];
[cell.thumbnailImageView addSubview:async];
}
试试这个你的问题会解决。
try this your problem will solve.
这篇关于如何在UITableView中向图像添加活动指示器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!