• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
wrapping a really long word in an UILabel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wrapping a really long word in an UILabel


  • Subject: wrapping a really long word in an UILabel
  • From: Koen van der Drift <email@hidden>
  • Date: Sun, 22 Sep 2013 11:51:27 -0400

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@hidden)

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:

This email sent to email@hidden


  • Prev by Date: Re: How to properly flip a UIView's coordinate system
  • Next by Date: Re: CGImageRef as a property of a cocoa object
  • Previous by thread: Re: How to properly flip a UIView's coordinate system
  • Next by thread: Grouped table view appearance in iOS 7
  • Index(es):
    • Date
    • Thread