您的位置:首页 > 产品设计 > UI/UE

UITableViewCell中如何添加图片数组

2015-12-20 18:16 357 查看
步骤一:

在控制文件中引入系统的方法

步骤二:

声明一个数据:可变数组

@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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息