我有一个自定义UITableViewCell
与UILabel
内Storyboard
。我动态地设置了这个UILabel
的文本,我需要相应地调整它的宽度,因为在这之后我有另一个必须保持并排的UILabel
。UILabel动态宽度与单元格上的sizeToFit
我与
> MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
> author = @"Some dynamic text";
> cell.authorLabel.text = author;
> [cell.authorLabel sizeToFit];
会发生什么努力: 在第一渲染UILabel
只是不断被上storyboard
设置宽度,因此无论是文本裁剪或之后有太多的空间。
滚动后,单元格出列并正确应用sizeToFit
方法,但已经太迟了,因为第二个UILabel
已被放置在错误的位置。 (由于名誉限制较低,无法发布图片)
任何想法?
见[这个问题](http://stackoverflow.com/questions/1947970/dynamic-calculation-of-uilabel-width-in-uitableviewcell?rq=1 ) –