iOS 8 self sizing cells don't work with UITabl

2019-09-09 01:22发布

问题:

I can't get iOS 8 self sizing cells to work with the default cell style UITableViewCellStyleSubtitle and numberOfLines = 0. It seems that only default cell styles with multiple labels have this issue. The basic style works fine.

Here is sample project demoing the issue: https://github.com/stevemoser/SelfSizingDemo-DefaultCellStyle

Original code taken from this blog post that uses a custom table view cell: http://www.appcoda.com/self-sizing-cells/

回答1:

The basic cell types totally support self-sizing cells....You just need to remember to set the

self.tableView.estimatedRowHeight = 44;
self.tableView.rowHeight = UITableViewAutomaticDimension;

Add those 2 lines and like magic it will work for you