UITableView注意点
来源:互联网 发布:淘宝拉卡拉pos机 编辑:程序博客网 时间:2024/06/06 00:45
一.当自定义了cell(假如名字为myCell),在控制器中想调用这个cell中的某个属性(假如为name)时,不可直接用myCell.name
,这样调用会发现myCell.name中为空,实际代码应该为:
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:1 inSection:0];//假如这个cell在tableView中为第0个分区的第一行(没有分区时即为0分区) myCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 再调用cell.name即可了
二.当在footVIew或者headerView中需要根据请求的连接来创建一些label或者button的,即根据连接的请求需要即时刷新footVIew或者headerView,则此时定义footVIew或者headerView时不可用 UILabel *headerLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
headerLabel.text = @"这里是表头";
_tableView.tableHeaderView = headerLabel;
这种方法。而应该用
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UILabel *header = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 20)]; return header;}
并注意不要忘了 //自定义高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 20;
}
三.grpup形式的tableView是有组尾的,要想让其消失代码应为:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.00000001;//注意不应该返回0}
另注:tableView中某些情况下,需要将组头或者组尾隐藏掉时,除了隐藏的代码外,还应该将组头或者组尾的返回高度设置为return 0.00000001;不是返回为0
四.获取指定的cell
//获取第0个分区的第1个cell NSIndexPath *indexPath=[NSIndexPath indexPathForRow:1 inSection:0]; ShopAnalysisType1Cell *cell = [_shopAnalysisTable cellForRowAtIndexPath:indexPath];
0 0
- UITableView注意点
- UITableView的注意点
- UITableView注意点
- UITableView进阶注意点
- ##iOS##关于UITableView的tableHeaderView的注意点
- 关于UITableView 的一些重用技术注意点
- 注意点
- 注意点
- 注意点
- 注意点
- 注意点
- UITableView相关技术点
- UITableView重要点整理
- UITableView重要点整理
- Split遇到“.”点注意点
- Java混淆点、注意点
- 食物注意点
- 制造中的注意点
- YII2自定义日志
- C++项目中的extern "C" {}
- View 和MotionEvent 提供的获取坐标的方法
- 从头认识SpringBatch批处理框架---Chunk拦截器
- UI设计师不可不知的安卓屏幕知识
- UITableView注意点
- 实用的欢迎页开源库 AppIntro
- sqlserver数据库存储的日文显示为乱码的解决方案
- 免安装mysql 5.7.11 64位安装配置,无法启动问题
- 灵活运用OPC驱动增强通讯效率和可靠性
- 第3章 Wishbone片上总线
- JAVA自动化测试中多数据源的切换
- 关于Eclipse的如何更改字体及颜色等
- vnc录屏