简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM