Custom UITableViewCell. Failed to apply UILineBreakModeTailTruncation

∥☆過路亽.° 提交于 2020-01-14 05:43:09

问题


I am creating a custom UITableViewCell with UILabel inside.

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?

Thanks.


回答1:


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;

You should then find your LineBreakMode setting works...



来源:https://stackoverflow.com/questions/1333809/custom-uitableviewcell-failed-to-apply-uilinebreakmodetailtruncation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!