Hi,

I have a custom UITableViewCell with several UILabels to display text. One of 
the labels can have a really long word, and I like it to be split in multiple 
lines so everything is visible, but without hyphens.


So I set numberOfLines to 0, and am using this to calculate the height of the 
label (to size the cell):

        CGSize mySize = [reallyLongWord sizeWithFont: labelFont
                                           constrainedToSize: 
CGSizeMake(260.0f, FLT_MAX)
                                               lineBreakMode: 
NSLineBreakByCharWrapping];

However, what I see is just one line, and just the beginning part of the string 
that fits in that width. The rest of the string is not visible. When I print 
the calculated size, I can see that for really long words, mySize.height 
adjusts properly to multiples of 19.  So, mySize is calculated properly, just 
the string is not completely shown.  I tried increasing the label height, but 
that didn't work either.



On iOS7 I switched to:

        CGRect myRect = [reallyLongWrap boundingRectWithSize: 
CGSizeMake(260.0f, FLT_MAX)
                                                       options: 
NSStringDrawingUsesLineFragmentOrigin
                                                    attributes: 
@{NSFontAttributeName: labelFont}
                                                       context: nil];

And here it works as expected.



Any ideas how I can fix this?


Thanks,

- Koen.
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to