开发者

UITableview to autowrap long text

How can I get a UITable开发者_运维知识库View to automatically wrap text which is longer than the width of the cell?


You need to dynamically determine the height of the cell, and set your label so that it autosizes itself. There's a fairly comprehensive explanation here: http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/


Set the "setNumberOfLines" property of the label to wrap the text to required number of lines. If you don't want the .... at the end of the text if it is too long then

label.lineBreakMode = UILineBreakModeWordWrap;

or if you want to show the ... after the text then don't use the above code.

All the best.


See the options for the lineBreakMode of the UILabel inside the UITableViewCell here.

hth
–f

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜