I am working on an ios application using object c, and I have a problem with uilabel with which I could use some help. Basically, I have a shortcut that can resize to fit the text it will display, but it has the maximum height that it can be. the label itself has a fixed width at all times. I included UILineBreakModeWordWrap and UILineBreakModeTailTruncation to make the text fit and truncated, but this causes the text to trim the tail too soon when it has only one word left. instead of moving it to the next line when there is still space, it just truncates it.
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, fixedWidth, 0); self.lineBreakMode = UILineBreakModeWordWrap | UILineBreakModeTailTruncation; self.numberOfLines = 0; [self sizeToFit];
Is there anyway a search where uilabel actually truncates the text, so I can check the height of the label and add to it if there is still room? I always tried to add an extra line to the height when there is room, and this avoids early truncation, but then I left with an inconsistent size over the whole label. Any ideas on this subject would be greatly appreciated.
ios objective-c uilabel
glogic Jan 24 '12 at 10:50 2012-01-24 10:50
source share