UITableViewAutomaticDimension return -1

Hi, I am making a tableviewcontroller class, and I want to get the cell height dynamically, so I use UITableViewAutomaticDimension, but it always returns me -1. A.

tableView.rowHeight = UITableViewAutomaticDimension println("\(tableView.rowHeight)") tableView.estimatedRowHeight = 44 

when i do tableView.rowHeight = 44 everything works fine. My superclass is a UIViewController.

0
ios ios8 swift
source share
1 answer

You can only use UITableViewAutomaticDimension for the footer / header height, and only if you implement:

 - tableView:titleForHeaderInSection: 

If you implement:

 - tableView:viewForHeaderInSection: 

it will not work. UITableViewAutomaticDimension not intended to set row height. Use rowHeight and specify your value or implement:

 - tableView:heightForRowAtIndexPath: 
+3
source share

All Articles