views:

548

answers:

2

Hello,

I'm using UITableViewCellStyleValue1 in my table and setting some text for both the textLabel and detailTextLabel. In one cell the detail text label is a long URL, which overlaps with the textLabel (normally "URL" and then shortened to "U."), which sucks. Is there a way to prevent this, except from creating my own label and putting it at the same spot where the default one is?

Thanks!

A: 

You need to set the minimum font size for the TextLabel. UILabel Class Reference

adjustsFontSizeToFitWidth

A Boolean value indicating whether the font size should be reduced in order to fit the title string into the label’s bounding rectangle.

@property(nonatomic) BOOL adjustsFontSizeToFitWidth

Discussion

Normally, the label text is drawn with the font you specify in the font property. If this property is set to YES, however, and the text in the text property exceeds the label’s bounding rectangle, the receiver starts reducing the font size until the string fits or the minimum font size is reached.

The default value for this property is NO. If you change it to YES, you should also set an appropriate minimum font size by modifying the minimumFontSize property. Availability

* Available in iPhone OS 2.0 and later.

See Also

*   @property font
*   @property minimumFontSize
John Wang
Thanks, but that is not the ideal solution as the URL address becomes so tiny that it's unreadable (sorry I forgot to mention this). The better option is to cut off the URL on the right and then I will display the whole text when the user clicks on the cell. So, cutting off the detailTextLabel on the right (like URL http:///www.site.com/somestgg..." is cool, but "U. http://www.site.com/somestuff..." is not!
Lex
A: 

I am struggling with the exact same problem and can't find the solution anywhere... it's really hard to believe that!

Did you manage to find any solution?

Joshua