Why UITableViewCell multiple lines only going to half of cell width?
I am doing this:
cell.textLabel.font = [UIFont systemFontOfSize:16.0]; cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; cell.textLabel.numberOfLines = 0; cell.textLabel.text = [self.myArray objectAtIndex:indexPath.row];
But the problem is that when it wraps the words and makes multiple lines, the UITableViewCell is not taking advantage of the full cell width. Instead it is starting the next line when the line is about in the middle of the cell.
Why is this?
I usually check the width of the label by setting it's bacgroundColor property.
cell.contentView.backgroundColor = [UIColor redColor];
This way you can see the actual width of the label rect.
I can only try to guess that the problem is the cell style you are using. Check if you are using: UITableViewCellStyleDefault in the line :
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"id"];
Using other cell styles might small your label.
with your code it will find all the the words in cell and which will not fit in that cell that word will be in nect line. if you dont want like that than you can use UILineBreakModeCharacterWrap instead of UILineBreakModeWordWrap..