How to make text in UITableViewCell wordwrap?

I have a grouped UITableView with several sections. The text in some cells may take quite a while, I was wondering how I can do text wrapping?

+3
source share
4 answers

eg,

textLabel.numberOfLines = 0;

You can set this to a fixed number of lines if you want. It might be a good idea to install lineBreakMode, and you probably need to implement:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

via:

NSString sizeWithFont:constrainedToSize:
+10
source

You will indicate the number of lines that will be used in the text. Setting it to zero will automatically wrap it.

cell.textLabel.numberOfLines=0; // line wrap
+4

numberOfLines > 1 lineBreakMode. , , . tableView: willDisplayCell: forRowAtIndexPath: .

+2

, Custom Cell Height, ? , , , , ? ,

+1

Source: https://habr.com/ru/post/1747044/


All Articles