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..

Need Your Help

SignalR difference between On and Subscribe of IHubProxy

c# signalr signalr-hub

What are the differences between On and Subscribe methods available in IHubProxy interface. When should one use one over the other

Data recognition, parsing, filtering, and transformation — GUI?

python ruby perl kettle data-manipulation

Looking for a non-cloud based open source app for doing data transformation; though for a killer (and I mean killer) app just built for data transformations, I might be willing to spend up to $1000.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.