How to add activity indicator to the image in UITableView?

妖精的绣舞 提交于 2019-12-02 11:18:56

You can use "AsyncImageView" class files it will load image synchronically and it shows the activity indicator while image loading

You can download "AsyncImageView" class files from following link:- https://www.dropbox.com/s/peazwjvky9fsjd7/Archive.zip

in .m file import AsyncImageView Class

 #import "AsyncImageView.h" 

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!