Tableview自定义分组头,分组尾
来源:互联网 发布:linux设置为中文后死机 编辑:程序博客网 时间:2024/05/07 14:25
自定义组头组尾,可以想到需要使用下面的代理方法:
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; // custom view for header. will be adjusted to default or specified header height- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; // custom view for footer. will be adjusted to default or specified footer height
所以我们需要自定义view。但是uiview不支持带XIB,如何实现?这里有一个技巧。我们创建一个uiview叫做myview。然后创建一个空的xib.里面拖拽出你想要的界面。然后将他们绑定
如下图:
自定义view就做好了,名字叫做myview。下面把它放到tableview中
//设置分区头的高度-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 100;}//设置分区头视图 (自定义分区头 一定要设置分区头高度)-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *headerview = [[NSBundle mainBundle]loadNibNamed:@"myview" owner:self options:nil].firstObject; headerview.backgroundColor = [UIColor grayColor]; return headerview;}-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 100;}-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ UIView *footerview = [[NSBundle mainBundle]loadNibNamed:@"myview" owner:self options:nil].firstObject; footerview.backgroundColor = [UIColor yellowColor]; return footerview;}
实现效果如下:
阅读全文
0 0
- Tableview自定义分组头,分组尾
- [IOS]Tableview分组
- tableView 分组间距
- tableView分组 头部悬停
- iOS tableView分组
- 使用TableView进行分组
- lightswitch C1FlexGrid 分组列头自定义标题处理
- 实现可折叠的分组tableview
- tableView分组显示,悬挂效果
- 【iOS】iOS开发TableView分组
- tableView分组头部标题处理
- tabLeview的静态分组使用
- 分组
- 分组
- 分组.
- 分组
- 分组
- 分组
- 当Hbase往mysql中导数据出现的问题
- 套利进阶——简单易行的分级基金套利
- windows环境搭建PHP环境
- jieba分词使用代码示例
- Struts2框架自学之路——结果页面的配置
- Tableview自定义分组头,分组尾
- [leetcode]: 118. Pascal's Triangle
- linux 其他常用命令
- EditPlus注册码在线生成
- redis + messagepack 消息队列
- 观察者模式 Observer Pattern
- 了解Oracle RAC Brain Split Resolution集群脑裂协议
- 在XML中为layout设置阴影
- 模拟分页,FIFO,LRU,OPT算法