views:

61

answers:

2

hi, when you enter a too long sentence for the iphone it automaticaly add a "..." at the end to show you there is other stuff you don't see right. I want to delete those "...".

image : alt text

+2  A: 

Well, I'm assuming you're using a label. Look into the "lineBreakMode" property. Your solution will probably involve some combination of that property in conjunction with the "numberOfLines" property. For example, setting the "numberOfLines" property to 0 will automatically increase the height of a label to fit all text. So using that with a UILineBreakModeWordWrap would probably do the trick.

UILabel *label = [[UILabel alloc] init];
label.numberOfLines = 0;
label.lineBreakMode = UILineBreakModeWordWrap;
label.text = @"Light beer 5% 10oz Glass served cold";
[label release];
0bj3ct.m3th0d
ok thanks, i don't understand totally what you said but i need to reduce the text size to fit the tableview cell. how to i put numberoflines property to 0 ?
the1nz4ne
ok i understand but i can't do that cuz its a string :S
the1nz4ne
ok i almost got it , my tableview cell is filled with a string, how can i do it to fill with a label?
the1nz4ne
ok it works guys thanks but it tell me a warning... 'deprecated"
the1nz4ne
You're likely set cell's text as cell.text = @"blabla" - that's deprecated method and you should use cell.textLabel.text = @"blabla" now. (or set string value to any other cell's labels)
Vladimir
A: 

You have several options for that:

  1. Set label's lineBreakMode property to UILineBreakModeClip - that way your sentence will just be clipped without "..." on the end
  2. Set label's adjustsFontSizeToFitWidth property to YES - label will automatically reduce font size to fit string into available space
  3. Make your UILabel have multiple lines - set its numberOfLines property to 0 and lineBreakMode to UILineBreakModeWordWrap. Although with this approach your label's height must be big enough to contain several lines...
Vladimir