Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

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

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

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

devon opened this issue Apr 25, 2012 · 11 comments

Comments

@devon
Copy link

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

@avaidyam
Copy link

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
Copy link
Author

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.

@avaidyam
Copy link

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

@devon
Copy link
Author

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.

@avaidyam
Copy link

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

@devon
Copy link
Author

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

@avaidyam
Copy link

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
Copy link
Author

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;

@avaidyam
Copy link

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

@devon
Copy link
Author

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];
}

@joshaber
Copy link
Contributor

This is fixed after merging #107

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants