Skip to content

UILabel Link Hit Detection too large for small labels. #570

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

Open
Think7 opened this issue Aug 14, 2015 · 4 comments
Open

UILabel Link Hit Detection too large for small labels. #570

Think7 opened this issue Aug 14, 2015 · 4 comments

Comments

@Think7
Copy link

Think7 commented Aug 14, 2015

Clicking on the word "would" actually activates the link.

Would

The method

- (TTTAttributedLabelLink *)linkAtPoint:(CGPoint)point

seems to be responsible.

Changing the CGRectInset values from -15.0f to -2.5f greatly improves touch accuracy in this case.

@getaaron
Copy link
Contributor

Thanks for the report, @Think7. Would you be interested in submitting a pull request to resolve this issue?

If it's causing problems for you, you may be able to work around the issue by disabling the link perimeter testing. It is disabled by default in the latest version. (I didn't test this out yet, so I'm not 100% that's the issue though.)

@Think7
Copy link
Author

Think7 commented Aug 14, 2015

I only installed the module early last night, has there been an update since then? If not then this issue might be in the latest version.

What i would like to test is to see if the size of the label affects the touch area. There night need to be some fancy maths done based on the label or font size but I'm not sure. Haven't tested this at all.

How do you disable the link perimeter testing?

Thanks for your help!

@getaaron
Copy link
Contributor

You disable it by setting extendsLinkTouchArea to NO, but if you are running the latest version, that's the default.

It looks like the bug is caused by linkAtPoint: and characterIndexAtPoint: both use self.bounds as the rect. Instead they should inspect textInsets and adjust the rect as necessary.

I won't have time to take a look at a fix for the next week or two, though. As a temporary workaround you could just set textInsets to CGRectZero and position the label differently.

@getaaron
Copy link
Contributor

@Think7 I'm back and starting to look more closely at issues. Were you able to resolve this or investigate this further?

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

2 participants