【问题标题】:Keep some cell height unchanged, while changing others保持某些单元格高度不变,同时更改其他单元格高度
【发布时间】:2016-04-29 20:29:34
【问题描述】:

我有一个静态单元格(具有不同高度)的 TableView,我试图在加载时隐藏一个单元格。我通过使用heightForRowAtIndexPath 并为要关闭的单元格返回0 来实现它,但是对于该函数,我需要返回一个值..

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
   if indexPath.section == 2 && indexPath.row == 5 {
       return 0
   }

   // here:

   return tableView.rowHeight  // changes default values of cells
   return UITableViewAutomaticDimension // changes too.

    }

我想返回单元格的任何高度。

我为 obj-c 找到了这个,我觉得它可以工作,但我不确定..我无法翻译它..

[super tableView:tableView heightForRowAtIndexPath:indexPath];

保持单元格高度不变的方法是什么?我应该对所有内容进行硬编码吗?

【问题讨论】:

    标签: ios swift uitableview tableviewcell heightforrowatindexpath


    【解决方案1】:

    只需调用super 实现:

    return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 2013-06-08
      • 1970-01-01
      • 2011-08-20
      • 2012-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多