知识点回顾-简单的TableView单组数据展示/多组数据展示
1 拖入TableView到UIView中,连线DataSource 2 3 1.实现数据源方法 4 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 5 { 6 return ; 7 } 8 9 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 10 { 11 return ; 12 } 13 14 2.根据指定的的cell样式创建cell 15 UITableViewCellStyleDefault 16 UITableViewCellStyleValue1 17 UITableViewCellStyleValue2 18 UITableViewCellStyleSubtitle 19 20 3.解析字典—>字典转模型—>取出indexPath位置对应的XMGWine模型 21 22 4.设置数据(用创建出来的cell对象直接点出里面子控件设置) 23 24 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 25 { 26 // 创建一个UITableViewCellStyleSubtitle样式的cell 27 UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]; 28 29 // 取出indexPath位置对应的XMGWine模型 30 XMGWine *wine = self.wineArray[indexPath.row]; 31 32 // 设置数据 33 cell.imageView.image = [UIImage imageNamed:wine.image]; 34 cell.textLabel.text = wine.name; 35 cell.detailTextLabel.text = [NSString stringWithFormat:@"¥%@", wine.money]; 36 cell.detailTextLabel.textColor = [UIColor orangeColor]; 37 //cell最右边的显示样式('>') 38 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 39 40 return cell; 41 } 42 43 多组数据展示 44 跟单组数据展示一样,但是数组里面又有数组,需要逐层转模型 45 /******************************************************** 46 1> plist解析: 47 以后遇到像这种复杂的plist,一层一层的往下解析. 48 最终的目的就是将所有的字典转成模型. 49 如果plist中字典在一个数组中,将来转出来的模型也放在一个数组中. 50 也就是将字典数组转成模型数组. 51 52 2> plist的好处:方便管理数据 53 *********************************************************/ 54 55 设置数据需要先拿出组模型,再拿出行模型 56 57 #pragma mark - <UITableViewDataSource> 58 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 59 { 60 return self.carGroups.count; 61 } 62 63 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 64 { 65 XMGCarGroup *carGroup = self.carGroups[section]; 66 return carGroup.cars.count; 67 } 68 69 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 70 { 71 UITableViewCell *cell = [[UITableViewCell alloc] init]; 72 73 // 设置cell右边的指示样式 74 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 75 76 // 取出indexPath位置对应的XMGCar模型 77 XMGCarGroup *carGroup = self.carGroups[indexPath.section]; 78 XMGCar *car = carGroup.cars[indexPath.row]; 79 80 cell.textLabel.text = car.name; 81 cell.imageView.image = [UIImage imageNamed:car.icon]; 82 return cell; 83 } 84 85 /** 86 * 告诉tableView第section组的头部标题文字 87 */ 88 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 89 { 90 XMGCarGroup *carGroup = self.carGroups[section]; 91 return carGroup.header; 92 } 93 94 /** 95 * 告诉tableView第section组的尾部标题文字 96 */ 97 - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section 98 { 99 XMGCarGroup *carGroup = self.carGroups[section]; 100 return carGroup.footer; 101 } 102 103 @implementation XMGCarGroup 104 + (instancetype)carGroupWithDict:(NSDictionary *)dict 105 { 106 XMGCarGroup *group = [[self alloc] init]; 107 group.header = dict[@"header"]; 108 group.footer = dict[@"footer"]; 109 110 // 将字典数组(装着车的字典) -> 模型数据(装着车的模型) 111 NSMutableArray *cars = [NSMutableArray array]; 112 for (NSDictionary *carDict in dict[@"cars"]) { 113 [cars addObject:[XMGCar carWithDict:carDict]]; 114 } 115 group.cars = cars; 116 117 return group; 118 }
make by-LJW
转载于:https://www.cnblogs.com/ljwiOS/p/5243988.html
知识点回顾-简单的TableView单组数据展示/多组数据展示相关推荐
- 【PHPWord】PHPWord生成图表-雷达图 | 隐藏图例、设置数值类别隐藏、展示多组数据
目录 预计达到的效果 什么是雷达图 在Word中如何生成雷达图 使用Chart生成雷达图 宽度和高度的单位都是EMU legend 图例 简单示例 美化样式 颜色设置Colors无效 无法配置数值最小 ...
- 【PHPWord】PHPWord生成图表-柱形图 | 设置数值类别展示、展示多组数据
目录 一.什么是柱形图 二.预期达到的效果 三.Word中是如何生成柱形图的 四.PHPWord生成柱形图 1.示例 2.调整数值 3.展示类别名称 4.隐藏值上的类别名 5.不能配置颜色和刻度 五. ...
- 比较两组数据的差异用什么图更直观_你真的懂如何展示数据吗?
↑ 关注 + 星标 ~ 有趣的不像个技术号每晚九点,我们准时相约 偶尔应金主爸爸要求改时间 大家好,我是朱小五 如何来展现的你的数据?是你有时不得不去思考的一个问题. 不同的展示方法,其效果往往差 ...
- Nature综述:Rob Knight带你分析微生物组数据(2020版)
文章目录 微生物组分析最佳实践 导读 摘要Abstract 背景介绍Introduction 实验设计Experimental design 图1. 微生物组实验设计中的注意事项 知识点1. 优秀工作 ...
- Nature综述:Rob Knight带你分析微生物组数据
微生物组分析最佳实践 Best practices for analysing microbiomes Impact Factor:34.648 https://doi.org/10.1038/s41 ...
- 使用MicrobiomeAnalyst统计和功能分析微生物组数据
文章目录 使用MicrobiomeAnalyst进行微生物组数据的全面统计.功能和元分析 摘要 背景Introduction 分析流程和界面设计 图1 MicrobiomeAnalyst工作流程概述. ...
- NatureProtocols:使用MicrobiomeAnalyst统计和功能分析微生物组数据
文章目录 使用MicrobiomeAnalyst进行微生物组数据的全面统计.功能和元分析 摘要 背景Introduction 分析流程和界面设计 图1 MicrobiomeAnalyst工作流程概述. ...
- MIMOSA2: 基于微生物组和代谢组数据的整合分析
文章目录 MIMOSA2: 基于微生物组和代谢组数据的整合分析 MIMOSA2的工作原理 MIMOSA2分析的主要步骤 软件部署 我们来看看MIMOSA2究竟做了什么? 运行计算 模式1:基于Gree ...
- 中文整合包_MIMOSA2: 基于微生物组和代谢组数据的整合分析
MIMOSA2:基于微生物组和代谢组数据的整合分析 MIMOSA2 升级自MIMOSA1.是 Borenstein 实验室(http://borensteinlab.com/ , 专注宏基因组系统 生 ...
最新文章
- Directx11教程(61) tessellation学习(3)
- ISE中ChipScope软件使用
- sed、cut和awk命令的使用
- img 标签 访问图片 返回403 forbidden问题
- java bitset用途_BitSet的用法
- css-样式重构-代码分享
- 2020webpack的面试题(webpack)
- Flex及AIR开发资源集合
- TCP粘包拆包基本解决方案
- JavaScript的setTimeout与setInterval执行时机
- 私域流量运营平台有哪些?
- AndroidStudio配置文件目录
- linux终端 字符界面 显示乱码
- 2020年12月特许金融分析师CFA考试难度分析!
- 《那些年啊,那些事——一个程序员的奋斗史》十三
- markdown标签
- Array.from和Array.of
- 交换机综合实验(华为)
- 数值计算方法之1——三种迭代公式对比
- Kong的插件: session
热门文章
- TFRecord tf.train.Feature
- 神经网络为什么需要多次epoch
- 汇编语言中栈及栈操作的实现
- Xcode couldn‘t find any iOS App Development provisioning profiles matching ‘com.example.***‘
- 2002年3月英伟达发布核弹GPU与大算力自动驾驶芯片
- MLIR(Multi-Level Intermediate Representation Compiler)架构 Infrastructure
- YOLOV4各个创新功能模块技术分析(二)
- 2021年大数据Hadoop(九):HDFS的高级使用命令
- python 把int类型转bytes以及把bytes 转int 类型(使用方法to_bytes ,from_byte, struct)
- Fragment 使用 show 和 hide 的方式实现切换 以及切换的时候Fragment 生命周期