UITableViewCell中如何添加图片数组
2015-12-20 18:16
357 查看
步骤一:
在控制文件中引入系统的方法
步骤二:
声明一个数据:可变数组
@property (nonatomic, strong) NSMutableArray *dataImage;
步骤三:
在 - (void)viewDidLoad{} 中指定代理,模拟数据的产生和请求
步骤四:
创建方法 - (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;
}
在控制文件中引入系统的方法
步骤二:
声明一个数据:可变数组
@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;
}
相关文章推荐
- 自定义uitableviewcell
- ios关于tableView的重用
- tableViewCell的不同高度创建
- 关于IOS 开发 中的一些小技巧
- iOS 中 cell下载图片思路 ,图解
- 通过修改父类,改变子类的cell的背景颜色及图片
- UITableView的组的自定义与cell的重用
- 微信聊天
- 复习ios --纯代码自定义 UITableviewCell
- 自定义tabelviewcell
- UITableViewCell的选中时的颜色设置和分割线颜色设置
- UITableView 实现异步加载图片之改进
- UITableView详谈
- 初入IOS之UI控件学习 UITableView
- UITableViewCell的重用问题
- 使用 Segue 傳送選取的 Table Cell 內容到下一個 View
- IOS-UITableView编辑模式
- iOS开发--storyboard+autolayout定制灵活高度tableviewCell
- 开发学习笔记--UItableView
- [iOS7]IOS7中UITableView的变化