I did get a proof of concept working with the TextKit classes. Turns out to
be possible, but more complicated and more moving parts than I would have
(naively?) expected. Beyond the complexity, the main drawback to that
approach is that it won't work on iOS 6, which the app in question still
supports.

I'd also considered trying something similar with Core Text. I *think* that
it might be possible to use a framesetter to do this, but I haven't
explored that yet. I'm sure it'd be at least as complicated as the TextKit
approach, though.

Was really hoping there was a two-line solution that was just eluding me.


On Fri, Jan 17, 2014 at 12:00 PM, T.J. Usiyan <griotsp...@gmail.com> wrote:

> I think that you might want NSLayoutManager. This depends on how you are
> displaying the text, NSLayout manager can allow you to both find out and
> change where truncation will happen. WWDC 2013 session 220 has some info
> about iOS's version of this which is very similar to Cococa's.
>
> TJ
>
>
> On Fri, Jan 17, 2014 at 10:43 AM, Sixten Otto <hims...@sfko.com> wrote:
>
>> Using the methods in the UIStringDrawing category on NSString, it's pretty
>> straightforward to measure the size of a string as it will appear on
>> screen, or to draw it into some constrained area. And I love that UIKit
>> handles all of the logic to truncate the string to fit.
>>
>> But I find myself in a situation where I'd like to actually obtain the
>> truncated version of the string. That is, given some text and a bounding
>> area, to have the system figure out how much will fit, and then tell me
>> that (whether returning the truncated string directly, or giving me a
>> character range that would fit, or whatever). So far, though, I can't find
>> any means to accomplish that.
>>
>> I feel like I must be missing something obvious, and I'm hoping someone
>> can
>> point me in the right direction.
>>
>> Thanks,
>> Sixten
>> _______________________________________________
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> 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/griotspeak%40gmail.com
>>
>> This email sent to griotsp...@gmail.com
>
>
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to