How to add activity indicator to the image in UITableView?

后端 未结 1 993
天命终不由人
天命终不由人 2021-01-28 02:02

I have created the Custom tableView and using custom tableView class in Other class to Show the tableView..

I am Loading the image

1条回答
  •  温柔的废话
    2021-01-28 02:50

    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.

    0 讨论(0)
提交回复
热议问题