Happiehappie
Happiehappie

Reputation: 1074

Dynamic table view cell height

I referred to http://www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift

However, in the example there is only 2 labels, in my cell I need to have 4.

It is shown in the tutorial that I have to change priority for my content hugging, but with 4 labels, can anyone teach me how should I change them?

I've added estimatedheightforrowatindexpath and tableView.rowHeight = UITableViewAutomaticDimension

my cell

But unfortunately my cell in now empty instead.

Apparently if i perform a segue from a table view and come back to it. The content loads, with dynamic height. P/S: I did add self.tableView.reloadData() in my viewWillAppear

Thanks in advance for all the help

Upvotes: 0

Views: 107

Answers (1)

Nilesh Patel
Nilesh Patel

Reputation: 6394

Set below properties to you all label objects, Then try

yourLabel.lineBreakMode = NSLineBreakByWordWrapping;
yourLabel.numberOfLines = 0;

Upvotes: 0

Related Questions