3
votes

I have a static UITableView with a UITableViewCell that contains a label. I have it set up to look nice right now, but when a user has their Dynamic Type turned to a larger setting, the label is cut off.

The UILabel has static ~15px constraints set up on all four edges of the UITableViewCell's content view.

How can I make the UITableViewCell's height change dynamically as the Dynamic Type adjusts the size of the UILabel's body formatted text.

2
use tableView:heightForRowAtIndexPath method.santhu

2 Answers

0
votes

Subscribe to UIContentSizeCategoryDidChangeNotification and when you get notified change your heightforRowAtIndexPath accordingly.

0
votes

I know you asked this question many years ago but, as you didn't share any solution here, I guess you didn't find one.

Standard table view cells content is automatically adjusted thanks to the cell-sizing feature. enter image description here

Constraints must be adapted in case of custom cells in order to obtain the desired rendering and let the cell-sizing work. enter image description here

If your table view cells don't size to fit content, try and use the properties UITableViewAutomaticDimension associated to estimatedRowHeight.

Finally, check out this WWDC video detailed summary dealing with the best way to build apps with Dynamic Type if the explanations above aren't enough.