• 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
more about NSAttributedString and truncation in iOS 6
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more about NSAttributedString and truncation in iOS 6


  • Subject: more about NSAttributedString and truncation in iOS 6
  • From: Matt Neuburg <email@hidden>
  • Date: Sat, 26 Jan 2013 09:20:09 -0800

I suppose no one remembers this:

http://www.cocoabuilder.com/archive/cocoa/323722-nsattributedstring-mysteriously-truncated-too-soon.html

Anyhow, I have finally realized after all this time that what I was seeing here was in fact the _standard_ behavior of NSAttributedString under iOS 6. If an NSAttributedString's paragraph style includes a `lineBreakMode` of `NSLineBreakByTruncatingTail`, and if that string is going to wrap in the width within which it is being drawn, then only the _first_ line is drawn (truncated).

The reason this confused me is that it isn't what I was expecting. It isn't what I was expecting because UILabel's truncation works (and always has worked) a different way: its `lineBreakMode` applied to a multiline string draws the _whole_ string, wrapping, as much as will fit in the full height of the label, and _then_ truncates the _last_ line.

So what we have now is that NSParagraphStyle and UILabel both have a `lineBreakMode` that can have a value of `NSLineBreakByTruncatingTail`, but they implement it very differently. (That is why I ended up having to achieve the same end using the NSAttributedString drawing option `NSStringDrawingTruncatesLastVisibleLine`.) Just wanted to make that perfectly clear for generations to come... :) m.


--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com


_______________________________________________

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

  • Follow-Ups:
    • Re: more about NSAttributedString and truncation in iOS 6
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Zombie object being messaged - why?
  • Next by Date: Re: more about NSAttributedString and truncation in iOS 6
  • Previous by thread: Re: Getting file type from Save dlog
  • Next by thread: Re: more about NSAttributedString and truncation in iOS 6
  • Index(es):
    • Date
    • Thread