自定义UITableViewCell.无法应用UILineBreakModeTailTruncation [英] Custom UITableViewCell. Failed to apply UILineBreakModeTailTruncation
问题描述
我正在创建一个带有UILabel的自定义UITableViewCell.
I am creating a custom UITableViewCell with UILabel inside.
当我在UILabel中设置太长的文本时,它与单元格的边界重叠. 看起来我已经指定了UILabel的所有必需属性,但仍然无法解决可能出错的地方.
When I am setting too long text into UILabel, it overlaps bounds of the cell. Looks like I have specified all required properties of UILabel, but still failed to resolve what could be wrong.
可能我应该配置表还是单元格?
Possibly I should configure a table or the cell?
您能建议我解决此问题的方法吗?
Could you please advice the way I can fix this?
谢谢.
推荐答案
您是否已将UILabel上的行数设置为大于1?行数默认为1,如果设置为1,则不会应用任何UILineBreakModes.
Have you set the number of lines on the UILabel to greater than 1? The number of lines defaults to 1, and if it is set to 1 then none of the UILineBreakModes will apply.
您可以按如下所示设置代码中的行数:
You can set the number of lines in code as follows:
UILabel *myLabel;
myLabel.numberOfLines = 2;
然后您应该会发现LineBreakMode设置有效...
You should then find your LineBreakMode setting works...
这篇关于自定义UITableViewCell.无法应用UILineBreakModeTailTruncation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!