AsyncDisplayKit icon indicating copy to clipboard operation
AsyncDisplayKit copied to clipboard

truncation string is not working reliablely with NSLineBreakByTruncatingTail

Open Yue-Wang-Google opened this issue 10 years ago • 7 comments

Test case:

Apply the following patch to the Kittens example:

--- /Users/wangyue/Downloads/AsyncDisplayKit-master/examples/Kittens/Sample/KittenNode.mm   2016-08-25 10:03:06.000000000 -0700
+++ Sample/KittenNode.mm    2016-08-25 13:00:22.000000000 -0700
@@ -98,8 +98,12 @@

   // lorem ipsum text, plus some nice styling
   _textNode = [[ASTextNode alloc] init];
+  _textNode.truncationMode = NSLineBreakByTruncatingTail;
+  _textNode.maximumNumberOfLines = 2;
   _textNode.attributedString = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
                                                                attributes:[self textStyle]];
+  _textNode.truncationAttributedText = [[NSAttributedString alloc] initWithString:@"\u2026 More"
+                                                                       attributes:[self textStyle]];
   [self addSubnode:_textNode];

   // hairline cell separator

See the first node in the following screenshot.

screen shot 2016-08-25 at 1 04 44 pm

Yue-Wang-Google avatar Aug 25 '16 20:08 Yue-Wang-Google

OK it seems ASDK calculate the truncation point either too early or too late. When using NSLineBreakByTruncatingTail, seems the line truncates too late. When using without, it happens too early. In a few cases two or three more words can be crammed to the last line, but ASDK just truncate a lot earlier.

Yue-Wang-Google avatar Aug 31 '16 21:08 Yue-Wang-Google

I have the same problem, It seems the line truncates too late, When using NSLineBreakByTruncatingTail and truncates too early when using NSLineBreakByWordWrapping.

Also when NSLineBreakByTruncatingTail breaks the line too late, it displays default truncate message instead of truncationAttributedText or additionalTruncationMessage.

Do you have any solution @Yue-Wang-Google ?

abbasmousavi avatar Oct 08 '16 22:10 abbasmousavi

@appleguy Could you please take a look at this issue?

abbasmousavi avatar Oct 23 '16 20:10 abbasmousavi

I'm also using .ByTruncatingTail. I'm adding an NSLinkAttributeName to the truncationAttributedText in order to get taps in textNodeTappedTruncationToken() in my delegate. It works perfectly if there are also linked URLs in the attributedText (with NSLinkAttributeNames). The token is consistently absent if there are no linked URLs in the attributedText. It just trails off with an ellipsis, not the specified truncationAttributedText, like the first cell in the image above.

jdee avatar Oct 27 '16 22:10 jdee

Related Issue: #1284

maicki avatar Nov 09 '16 03:11 maicki

@Adlai-Holler can you take a stab at figuring out if we can fix this in the 2.0 milestone?

garrettmoon avatar Nov 15 '16 21:11 garrettmoon

This issue was moved to TextureGroup/Texture#142

garrettmoon avatar May 01 '17 22:05 garrettmoon