I have a custom UITableViewCell
with a UILabel
inside on the Storyboard
. I set the text of this UILabel
dynamically and I need to resize the width of the UILabel
accordingly because after it I have another UILabel
that must stay side to side.
I am trying with
> MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
> author = @"Some dynamic text";
> cell.authorLabel.text = author;
> [cell.authorLabel sizeToFit];
What happens:
at the first render the UILabel
just keeps the width that is set on the storyboard
, thus either the text is cropped or there is too much space after it.
After scrolling, the cells are dequeued and the sizeToFit
method is applied properly, but is too late because the second UILabel
is already positioned on the wrong place.
(cannot post picture due to low reputation restriction)
Any idea?