TableView SectionHeaderView和SectionFooterView的高度

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;

iOS11之前的版本,在heightForFooterInSection和heightForHeaderInSection设置view的高度为0的时候,系统不会设置为0,会自动设置为默认高度。如:设置heightForFooterInSection为0:


对比.png

为了兼容之前的版本,正确的设置方法还是设置高度为:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.001f;
}
//iOS 11 设置头部高度 也必须实现这两个协议方法 设置一个新的view或者为nil
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc] init];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] init];
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,288评论 19 139
  • 1、通过CocoaPods安装项目名称项目信息 AFNetworking网络请求组件 FMDB本地数据库组件 SD...
    阳明AI阅读 16,105评论 3 119
  • 用到的组件 1、通过CocoaPods安装 2、第三方类库安装 3、第三方服务 友盟社会化分享组件 友盟用户反馈 ...
    SunnyLeong阅读 14,990评论 1 180
  • 很多人说迷茫,但又有谁不是一路迷茫一路成长呢? 迷茫真的不可怕,可怕的是迷茫还站在了原地,甚至于迷失了自己。 我们...
    小阿晴阅读 1,346评论 0 0
  • 为啥叫问号呢,是因为今天遇到一个选择题,作为我本人,我是认同的。作为我个人,我是拒绝的。我在想我该怎么做,是yes...
    80后假文青阅读 1,360评论 0 0

友情链接更多精彩内容