开发者

iphone programming obj-c : removing the "..."

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 http://img691.imageshack.us/img691/2159/screenshot20100602at095.png


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];


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜