美文网首页
UITableView相关

UITableView相关

作者: nuannuan_nuan | 来源:发表于2019-01-14 16:10 被阅读5次

group and plain style

iOS的tableView有两种样式:一种是plain(默认);一种是grouped。iOS系统的设置的样式就是grouped样式。这两种样式上是有很大差别的。我们用一张表格来对比下

sectionHeader/Footer plain grouped 备注
是否悬浮 悬浮 不悬浮 -
高度 默认为0 默认有一定的高度 如果不实现viewForHeaderInSection/viewForFooterInSection,header/footer背景色同tableView的颜色
分割线 默认无分割线 默认有分割线 可以通过把separatorStyle设置为UITableViewCellSeparatorStyleNone来取消header/footer的分割线

注意

  1. 如果为grouped style,我们要隐藏某个section header/footer,将heightForHeaderInSection/heightForFooterInSection里的实现返回值设置成0是无效的,设置成0等同于默认设置,而它的默认设置是有一定高度的,如果我们要隐藏特定的section header/footer可以用直接返回CGFLOAT_MIN

2.viewForHeaderInSection/viewForFooterInSection方法里不要自行创建header/footer view。虽然我们在这两个代理方法里创建的section header/footer,会被系统回收,但是频繁的创建和销毁对象对系统也有一定的开销,影响滑动体验。所以建议用将header,footer用forHeaderFooterViewReuseIdentifier注册到tableView中,然后依据identifier重用。注意这时的header/footer需要继承UITableViewHeaderFooterView

3.另外,iOS8以后tableView会默认设置estimatedSectionFooterHeightestimatedSectionHeaderHeightestimatedRowHeight。其实这个设置是为了在我们进行动态改变高度时默认的一个高度设置,在实际应用中我们可以不用对它们进行设置,如果你对这三个属性进行了设置,那么在iOS11上会出现一些问题,比如在动态计算高度的情景下,重新reload会出现tableView跳动的情况;heightForHeaderInSection/heightForFooterInSection代理方法没有调用的情况。这种情况下,直接将以上属性值设置为0即可。

相关文章

  • UITableView iOS8 侧滑删除

    刷新列表 UITableView 相关 UITableView 索引详细

  • iOS 优秀的第三方学习

    UITableView 相关 UITableView+FDTemplateLayoutCell 苹果官方开发文档 ...

  • UITableView相关

    关键词: 开发, iOS, tableView, 使用SnapKit+FDTemplateLayoutCell时c...

  • UITableView相关

    iOS开发之UITableView全面解析详细整理:UITableView优化技巧iOS 保持界面流畅的技巧

  • UITableView相关

    1、去掉UITableView上多余的分割线 设置UITableView的tableFooterView为fram...

  • UITableView 相关

    tableHeaderView 和 tableFooterView UITableView属性里的tableHe...

  • UITableView相关

    1、基础知识 样式 UITableView有两种样式(plain,grouped),其中plain为普通列表样式,...

  • UITableView相关

    group and plain style iOS的tableView有两种样式:一种是plain(默认);一种是...

  • UITableView 编辑模式详解

    UITableView 编辑模式详解 UITableView的相关编辑操作非常全,今天我们来做一个总结。跟编辑相关...

  • iOS 11 适配相关

    UItableview相关 手机更新到iOS 11 , UItableview出现cell间距扩大,头部偏移等情况...

网友评论

      本文标题:UITableView相关

      本文链接:https://www.haomeiwen.com/subject/vcxjdqtx.html