UILabel autoLayout doesn't work fine
I set UIlabel
to UITableViewCell
I want to dynamically increase the height UITableViewCell
, so I add some constraints with UIlabel
, When you type UIViewController
, the label and height are UITableViewCell
wrong, but if I scroll UITableViewCell
outside the screen and scroll back to the screen, then it works correctly, it's weird.
These are my storyboard limitations
UILabel in TableViewCell while entering UIViewController
It should be
I am trying to add some code (override UILabel)
-(void)layoutSubviews{
self.preferredMaxLayoutWidth = self.frame.size.width;
[super layoutSubviews];
}
and set the crawl priority with 1000
source to share
This is because the height of your label is larger than the text content. If you give it a background color, then you can see that. do not attach the bottom of the label to the bottom of the cell, it will stretch the height of the label.
or you can try
[lable sizeToFit];
after setting the string value of the label, this may fix the problem.
source to share