I have a custom UITableViewCell
with only one UILabel
. The UILabel
is potentially too long to fit as a single row, so I have to dynamically set the height of UITableViewCell
.
I set leading, top, and height(Greater or equal) constraints of UILabel
. Am I missing any constraints?
ProductDetailDescriptionTableViewCell *cell = (ProductDetailDescriptionTableViewCell *)[self productDetailDescriptionCellInTableView:tableView
indexPath:indexPath];
CGSize cellSize = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return cellSize.height + 1;
This is calculate height code in tableView:heightForRowAtIndexPath:
I also set preferredWith of UILabel
.
When I run my code, the height of cell is 0, label`s frame is
(0,-21,42,21)
I wish someone can help. Thank you very much!!!