I\'ve spent several days trying to figure this out, but there doesn\'t seem to be a solution. I have a very basic UITableView cell with two labels in it. One of them will be
I suggest you don't use stack view for this . Just take custom cell with Label according to your requirement and cell will resize automatically according to Label text size.
Check , here i have attached demo.
UITableview cell Autoresize According to textsize
Output :-
In viewdidload
super.viewDidLoad()
self.tblView.estimatedRowHeight = 100;
self.tblView.rowHeight = UITableViewAutomaticDimension;
self.tblView.setNeedsLayout()
self.tblView.layoutIfNeeded()
Dont forget to set Numberoflines=0 of UILabel property.
Edit :- If you need step by step guide regarding how to set constrain to UILabel ,
check this link ,
Adjust UILabel height depending on the text
Edit :- Here i have take 2 label in cell according to your above image. Just set constrain like this .
Label 1 :- Top , Leading , (Height and width According to your requirement)
Label 2 :- Top , Bottom , Leading from Label 1, Trailing from Superview