Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there an issue with Tableview support? #25

Open
dmathewwws opened this issue Feb 2, 2017 · 7 comments
Open

Is there an issue with Tableview support? #25

dmathewwws opened this issue Feb 2, 2017 · 7 comments

Comments

@dmathewwws
Copy link

Hi,

Ran the Demo project and it works perfectly, tried integrating into a tableview and even though it looks great visually, I ran into the following issues:

  • the handler is not triggered when I click on the attributed link portion of the label
  • When I click on any part of the label, the didSelectRowAt delegate method on the tableView is not triggered.

I made an example project, https://github.com/dmathewwws/FRHyperLabel-Tableview to showcase the issues I am talking about.

Thanks,
Daniel

@aravasio
Copy link

aravasio commented Mar 4, 2017

Just to add to this, I'm having this exact same issue. The handler is not triggering no matter what I try if I embed this label into a tableViewCell which is then contained in a tableView.

@koenvanderdrift
Copy link

Is there a solution for this?

@aravasio
Copy link

aravasio commented Jun 12, 2017

@koenvanderdrift Not that I know of. As far as I was able to track, there seems to be an issue with line 174: NSInteger indexOfCharacter = -1; or, rather, the fact that it never changes from -1 by not entering the following for instruction, which, I guess it follows, is caused by lines being am empty array.

Now, how that comes to be escapes my understanding of the lower levels of the SDK.

@alasmanis
Copy link

Having the same :/

@alasmanis
Copy link

alasmanis commented Jun 20, 2017

this seems to do the trick for me:
`- (NSInteger) characterIndexForPoint:(CGPoint) point {

// init text storage
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedText];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];

// init text container
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(self.frame.size.width, self.frame.size.height+100) ];
textContainer.lineFragmentPadding  = 0;
textContainer.maximumNumberOfLines = self.numberOfLines;
textContainer.lineBreakMode        = self.lineBreakMode;

[layoutManager addTextContainer:textContainer];

NSUInteger characterIndex = [layoutManager characterIndexForPoint:point
                                                  inTextContainer:textContainer
                         fractionOfDistanceBetweenInsertionPoints:NULL];

return (NSInteger)characterIndex;

}`
Courtesy Of https://stackoverflow.com/a/26806991

@aravasio
Copy link

@alamanis does this change impact functionality out of the tableview scope? if not, please consider creating a PR.

@JaisinghSisodia
Copy link

Hello
I am having same issue in tableview.While having different words handler working fine.But if word are used in more than one times in cell .so that word is not identifying the handler.If anyone solved this poblem let me know

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

No branches or pull requests

5 participants