第三方加载图片

#import "TableViewCell.h"
#import "ImageModal.h"
// 下载图片(MRC)
#import "UIImageView+WebCache.h"
@implementation TableViewCell
#pragma mark - 给cell赋值方法
- (void)setCellModal:(ImageModal *)modal
{
    // 第三方 可以付动态图
    [self.pictureImageView sd_setImageWithURL:[NSURL URLWithString:modal.imageUrlString] placeholderImage:[UIImage imageNamed:@"5.png"]];
}
cellForRowAtIndexPath

// cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"TableViewCell";
    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    ImageModal *modal = self.dataArray[indexPath.row];
    [cell setCellModal:modal];
    cell.titleLabel.text = modal.title;
    return cell;
}

利用第三方 MBProgressHUD

#pragma mark - 网络请求
- (void)loadDataFromNetWork
{
    NSString *urlString = @"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/activitylist.php";

    // 显示进度条(解析数据前)
    [MBProgressHUD showHUDAddedTo:self.mainTableView animated:YES];

    // 解析数据(第三方)
    JSONAnalysis *json = [[JSONAnalysis alloc] initWithGETRequest:urlString];
    [json didFinishUsingBlock:^(id jsonObject) {

        // 解析
        NSArray *array = jsonObject[@"events"];

        for (NSDictionary *dict in array) {
            ImageModal *modal = [[ImageModal alloc] init];
            [modal setValuesForKeysWithDictionary:dict];
            modal.imageUrlString = dict[@"image"];
            [self.dataArray addObject:modal];

            // 隐藏进度条(解析完数据)
            [MBProgressHUD hideHUDForView:self.mainTableView animated:YES];
        }
        // 刷新cell(解析完数据)
        [self.mainTableView reloadData];
    }];
}
清除缓存
    // 清除缓存
    [[SDImageCache sharedImageCache] cleanDisk];
    [[SDImageCache sharedImageCache] clearDisk];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值