Xcode 6 iOS 8 UITableView rowHeight property returns -1

Michal Shatz picture Michal Shatz · Sep 18, 2014 · Viewed 9.2k times · Source

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.

Answer

Rigel Networks picture Rigel Networks · Sep 18, 2014

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/