Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Dictionary popup of TUITextRenderer does not work on 10.7.3? #105

Closed
devon opened this Issue Apr 25, 2012 · 11 comments

Comments

Projects
None yet
3 participants

devon commented Apr 25, 2012

double tap with three fingers with throw exceptions:

2012-04-25 10:22:05.277 Note[78887:403] -[__NSCFType lineBreakMode]: unrecognized selector sent to instance 0x1010be310
objc[78887]: EXCEPTIONS: throwing 0x1010c9d38 (object 0x1010d27d0, a NSException)
objc[78887]: EXCEPTIONS: searching through frame [ip=0x7fff93c6ae79 sp=0x7fff5fbfc800] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: searching through frame [ip=0x7fff874d9e72 sp=0x7fff5fbfd800] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: searching through frame [ip=0x10c28bcd4 sp=0x7fff5fbfdbf0] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: searching through frame [ip=0x10c28e0db sp=0x7fff5fbfdc70] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: catch(NSException)
objc[78887]: EXCEPTIONS: unwinding through frame [ip=0x7fff93c6ae79 sp=0x7fff5fbfc800] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: unwinding through frame [ip=0x7fff874d9e72 sp=0x7fff5fbfd800] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: unwinding through frame [ip=0x10c28bcd4 sp=0x7fff5fbfdbf0] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: unwinding through frame [ip=0x10c28e0db sp=0x7fff5fbfdc70] for exception 0x1010c9d18
objc[78887]: EXCEPTIONS: handling exception 0x1010c9d18 at 0x10c28e161
2012-04-25 10:22:05.278 Note[78887:403] Lookup: Unhandled exception 'NSInvalidArgumentException' caught in __56+[LULookupDefinitionModule focusTermUsingQueue:handler:]_block_invoke_0
objc[78887]: EXCEPTIONS: finishing handler

Mmm, mind posting the code you used to configure this? (Partially because I haven't been able to get it to work either, and partially to help you :D)

devon commented Apr 25, 2012

I tried the latest example from twui, it works. I use and old twui branch(before ARC). I'm trying to figure it out.

Wait, is it enabled automatically? Doesn't seem to do that for me...

devon commented Apr 25, 2012

Yeah, it enabled automatically. git clone the latest version from https://github.com/twitter/twui.git, and run the example project.

Oh, I see. I will indeed do that. Was the triple-tap define on the table view cell labels?

devon commented Apr 25, 2012

Yeah, triple-tap on the table view, it will show up the dictionary. I think it's related to TUITextRenderer

Alright, will look into that and get back to you. I'm on a desktop at the moment, but tomorrow I'll test it on an MBP running 10.7.3.

devon commented Apr 25, 2012

I found the problem. Cannot popup the dictionary when add line height to TUIAttributedString.

ExampleTableViewCell *cell = reusableTableCellOfClass(tableView, ExampleTableViewCell);

TUIAttributedString *s = [TUIAttributedString stringWithString:[NSString stringWithFormat:@"good news cell %d", indexPath.row]];
s.color = [TUIColor blackColor];
s.font = exampleFont1;
s.lineHeight = 3;  // Add the line will see the problem
[s setFont:exampleFont2 inRange:NSMakeRange(8, 4)]; // make the word "cell" bold
cell.attributedString = s;

return cell;

Considerably faster than I could, I see. Now that we know that the issue is here, I can look into fixing it. Thanks!

devon commented May 8, 2012

Change the setLineheight to use the default method solve the problem, but i'm not sure is this a good solution for this:

- (void)setLineHeight:(CGFloat)f inRange:(NSRange)range
{
    // CTParagraphStyleSetting setting;
    // setting.spec = kCTParagraphStyleSpecifierLineSpacing;
    // setting.valueSize = sizeof(CGFloat);
    // setting.value = &(CGFloat){f};

    // CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(&setting, 1);
    // [self addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:(id)paragraphStyle, kCTParagraphStyleAttributeName, nil] range:range];
    // CFRelease(paragraphStyle);
    NSMutableParagraphStyle *p = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    [p setLineSpacing:f];
    [self addAttributes:[NSDictionary dictionaryWithObjectsAndKeys:(id)p, kCTParagraphStyleAttributeName, nil] range:range];
    [p release];
}
Contributor

joshaber commented May 11, 2012

This is fixed after merging #107

@joshaber joshaber closed this May 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment