5

I have created a custom view cell with a UILabel in it, I have set :

 cell.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
       cell.titleLabel.numberOfLines = 0;

and it's not going in multiple lines, why is this?

in the layoutSubviews I have:

- (void)layoutSubviews {
    [super layoutSubviews];

    CGRect frame = titleLabel.frame;
    frame.origin.y = 5;
    titleLabel.frame = frame;
}

and that's about all the settings I have, however for a long text put in the label in the cell it just won't word wrap:

enter image description here

adit
  • 32,574
  • 72
  • 229
  • 373

1 Answers1

2

What is the height of the label's frame? It needs to be tall enough to hold more than one line of text. Check out Adjust UILabel height depending on the text

Community
  • 1
  • 1
shawnwall
  • 4,549
  • 1
  • 27
  • 38
  • should this be set at the layoutSubview in the Cell class or inside the cellForRowAtIndexPath? – adit May 27 '11 at 00:48
  • in a UITextView, I used to do frame.size.height = title.contentSize.height; , but what is the equivalent of this in UILabel? – adit May 27 '11 at 00:50