UITableViewCell中如何添加图片数组

步骤一:
在控制文件中引入系统的方法

步骤二:
声明一个数据:可变数组

@property (nonatomic, strong) NSMutableArray *dataImage;

步骤三:
在 - (void)viewDidLoad{} 中指定代理,模拟数据的产生和请求

self.fv.tableView.dataSource = self;
[self makeData];

步骤四:
创建方法 - (void)makeData{} 定义数组

self.dataImage = [NSMutableArray array];
for (int i = 0; i < 8; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@”%d.jpeg”, i]];
[self.dataImage addObject:image];
}
步骤五:
创建 重用池,添加图片数组

  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@”main_cell”];
    if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@”main_cell”];
    }
    cell.imageView.image = self.data3[indexPath.row];
    return cell;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值