UITableViewCell 中的 UILabel 多行
我创建了一个带有 UILabel 的自定义视图单元格,我设置了 :
cell.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.titleLabel.numberOfLines = 0;
并且它不会分成多行,这是为什么?
在我的layoutSubviews中:
- (void)layoutSubviews {
[super layoutSubviews];
CGRect frame = titleLabel.frame;
frame.origin.y = 5;
titleLabel.frame = frame;
}
这就是我所拥有的所有设置,但是对于放入单元格标签中的长文本,它不会自动换行:
I have created a custom view cell with a UILabel in it, I have set :
cell.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.titleLabel.numberOfLines = 0;
and it's not going in multiple lines, why is this?
in the layoutSubviews I have:
- (void)layoutSubviews {
[super layoutSubviews];
CGRect frame = titleLabel.frame;
frame.origin.y = 5;
titleLabel.frame = frame;
}
and that's about all the settings I have, however for a long text put in the label in the cell it just won't word wrap:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

标签框架的高度是多少?它需要足够高才能容纳多行文本。查看根据文本调整 UILabel 高度
What is the height of the label's frame? It needs to be tall enough to hold more than one line of text. Check out Adjust UILabel height depending on the text