【问题标题】:IOS Dev - How to make those empty table cells invisible?IOS Dev - 如何使那些空的表格单元格不可见?
【发布时间】:2014-07-26 11:49:35
【问题描述】:

正如您在此处看到的,我只有 2 个数据用于测试,它们已加载到表视图中。这很好。但是,还有很多空单元格也被自动生成了。

如何让这些空单元格不可见?

【问题讨论】:

标签: ios objective-c uitableview


【解决方案1】:
yourtableViewname.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
 { 
     return 0.01f;
 }

对于 iOS 7

 self.yourtableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

【讨论】:

    【解决方案2】:

    这应该可行:

    self.tableView.separatorColor = [UIColor clearColor];
    self.tableView.backgroundColor = [UIColor clearColor];
    

    【讨论】:

      【解决方案3】:

      您可以在加载视图时降低 tableview 的整体高度。根据总单元格高度计算表格视图的高度。将表格高度最大值分配给屏幕高度。

      【讨论】:

      • 如果可以的话,贴一些示例代码来帮助提问者。
      猜你喜欢
      • 2018-11-22
      • 2013-05-26
      • 1970-01-01
      • 2016-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      相关资源
      最近更新 更多