我试图创建一个UITableViewCell
与许多项目里面,但我有UILabels
问题。调整UILabel在自定义UITableViewCell内部的问题
当使用UITableViewCell
,TextLabel
和DetailTextLabel
默认样式只得到适当的高度,以适应内容,我只有用heightForRowAtIndexPath
计算row height
。
但随着我的定制cell
,UILabels
不resize
他们的高度,始终保持我在界面生成器设置size
,我想这
CGRect frame;
cell.title.text = item.title;
frame.origin = cell.title.frame.origin;
frame.size = [item.title sizeWithFont:[UIFont boldSystemFontOfSize:17]
constrainedToSize:CGSizeMake(FB_Cell_width, 4000) lineBreakMode:cell.title.lineBreakMode];
cell.title.frame = frame;
但UILabel
大小不会改变。
我尝试:
cell.title.text = item.title;
[cell.title sizeToFit];
但规模依然不改。
如何以及在哪里需要更改UILabel
框架以适合其内容?
编辑:我只是解开使用autolayout选项,现在它似乎工作。
也许在自动口罩可以帮助。或者,也许你可以使用'sizeWithFont'。 – dasdom 2013-05-13 11:43:00