美文网首页
UITableView 分组第0组组头不显示原因

UITableView 分组第0组组头不显示原因

作者: GC风暴 | 来源:发表于2017-01-02 22:57 被阅读0次

    默认第一组高度为0
    需要在代理方法中动态设置分组组头的高度, 既可以显示第0组组头;

    pragma mark - 设置组头高度就可以显示分组第一组的组头

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
        return 50;
    }```
    
    如果不需要组尾视图, 可以动态设置组尾视图的高度为0.001, 即可隐藏组尾视图;
    
    • (void)setupUI {
      // 如果需要组头, 则设置成分组表单
      UITableView *tv = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
      [self.view addSubview:tv];

      tv.rowHeight = 73;
      tv.sectionHeaderHeight = 50;
      tv.sectionFooterHeight = 0.001;
      tv.dataSource = self;
      tv.delegate = self;
      [tv registerClass:[CHRecentContaceCell class] forCellReuseIdentifier:cellId];
      [tv registerClass:[CHHomeHeaderView class] forHeaderFooterViewReuseIdentifier:cellHeaderId];
      }```

    相关文章

      网友评论

          本文标题:UITableView 分组第0组组头不显示原因

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