【问题标题】:Xcode 6 iOS 8 UITableView rowHeight property returns -1 [duplicate]Xcode 6 iOS 8 UITableView rowHeight 属性返回-1 [重复]
【发布时间】:2014-09-18 14:39:24
【问题描述】:

我在我的项目中的 Xcode 中有一个 UITableView,我在 StoryBoard 中将 rowHeight 设置为 44

在 iOS7 中一切正常,但在 iOS8 中 rowHeight 返回值 -1 导致我的表格视图不显示。

【问题讨论】:

  • 确实是重复的。 @Js Lim 在重复问题中的回答解决了这个问题。

标签: objective-c uitableview ios8 xcode6 row-height


【解决方案1】:

在 iOS 8 中,Apple 为 UITableView 引入了一项称为 Self Sizing Cells 的新功能。 如果要在可变高度的表格视图中显示动态内容,则需要手动计算行高。

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

这里是演示http://www.appcoda.com/self-sizing-cells/

【讨论】:

  • 谢谢,但内容不是动态的,所有单元格的单元格高度始终相同。
猜你喜欢
  • 1970-01-01
  • 2014-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-27
相关资源
最近更新 更多