I have following UITableViewCell prototype on the storyboard.
https://i.sstatic.net/FhF5y.png
It has three constaraints, left,top,and right distance from superview. UIlabel has number of lines = 0
When i assign text to the UILabel i have unneeded top padding on some uilabels. For example first cell on the screenshot. How to get that text will be always top aligned?
I solved issue myself. Seems that auto layout doesn't update label preferredMaxLayoutWidth so this will lead for incorrect formatting. For example when you change your orientation.
So to solve this i subclass UILabel and override layoutSubviews
- (void) layoutSubviews {
[super layoutSubviews];
self.preferredMaxLayoutWidth = self.bounds.size.width;
}