轻量级UIImageView分类缓存 库 AsyncImageView 使用

一:

二:使用

   主要演示结合UITableview的使用

    demo代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        //create new cell
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        
        //common settings
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
        cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
        cell.imageView.frame = CGRectMake(0.0f, 0.0f, 44.0f, 44.0f);
        cell.imageView.clipsToBounds = YES;
    }
    else
    {
        //cancel loading previous image for cell
        [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.imageView];
    }
    
    //set placeholder image or cell won't update when image is loaded
    cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];
    
    //load the image
    cell.imageView.imageURL = self.imageURLs[(NSUInteger)indexPath.row];
    
    //display image path
    cell.textLabel.text = [[(NSURL *)self.imageURLs[(NSUInteger)indexPath.row] path] lastPathComponent];
    
    return cell;
}
View Code

相关文章:

  • 2021-04-19
  • 2022-03-06
  • 2022-02-17
  • 2022-12-23
  • 2022-02-13
  • 2021-07-09
  • 2021-07-20
  • 2022-02-14
猜你喜欢
  • 2021-08-10
  • 2021-11-21
  • 2022-12-23
  • 2021-07-29
  • 2021-12-01
  • 2021-10-05
相关资源
相似解决方案