ios - 保持一些单元格高度不变,同时改变其他的

标签 ios swift uitableview heightforrowatindexpath

我有一个静态单元格的 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];

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

最佳答案

只需调用super实现即可:

return super.tableView(tableView, heightForRowAtIndexPath: indexPath)

关于ios - 保持一些单元格高度不变,同时改变其他的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36946951/

相关文章:

ios - 如何使用 GCDAsyncUdpSocket 在局域网中广播?

ios - 如何使用 quartzcore 框架闪烁 UITextview 的文本

ios - Apple ARKit (Augmented Reality Kit) 给出断言失败的错误信息

ios - 如何使图像对应于 NSMutableArray 中的每个对象 - xcode 7.3

ios - 如何使用 NSUserDefaults 将 UIImages 保存在应用程序目录中并在 UITableViewCell 中显示它们?

ios - 在 initWithCoder : not working 中设置自定义 UITableViewCell 的样式

ios - 如何从数字键盘 Xcode 9 Swift 4 调用 textFieldShouldReturn

ios - 线程 1 : Fatal error: Unexpectedly found nil while unwrapping an Optional value when testing cocoapod

ios - TableView Load More 正在不停地获取

ios - 如何在 tableview 中添加额外的行,除了 swift 中的两个单元格