Xcode 6 iOS 8 UITableView rowHeight property returns -1 [duplicate]

帅比萌擦擦* 提交于 2019-12-10 10:56:45

问题


I have a UITableView in Xcode in my project and I set rowHeight to be 44 in StoryBoard.

In iOS7 everything is fine but in iOS8 rowHeight returns a value of -1 which cause my table view not being displayed.


回答1:


In iOS 8, Apple introduces a new feature for UITableView known as Self Sizing Cells. If you want to display dynamic content in table view with variable height, you would need to calculate the row height manually.

tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension

Here is demo http://www.appcoda.com/self-sizing-cells/



来源:https://stackoverflow.com/questions/25915716/xcode-6-ios-8-uitableview-rowheight-property-returns-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!