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

[Fix] Accessibility element's bounding rect will get wrong if the con… #803

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mishidexfc
Copy link

@Mishidexfc Mishidexfc commented Oct 28, 2019

Repro steps:

  1. Using AddLinkToURL: to add two urls inside the text, such as ‘Affogato’ and ‘mylink’.Note that the text must contain ‘\n’ character to repro this bug.
    label.text = @"Affogato: Espresso served over gelato. Traditionally vanilla is used, but some coffeehouses or customers use any flavor \n \n 123 mylink.";

  2. If the label’s layout was not set correctly before adding the link, the last accessibility element will get the wrong boundingRect (all zero) from the return value of boundingREctForCharacterRange:

  3. boundingREctForCharacterRange: using label’s bounding size to measure the position of the highlighted element but the textContainer seems to ignore the ‘\n’ character will have additional line.

  4. Thus, if user setting the correct frame such as using sizeToFit, it works fine. But if the user calls it later after adding the link, the position of accessibilityElement will get wrong.

Solution:
NSTextContainer’s size does not need to be the same as the label’s bounding size.
Instead, we can use
CGSizeMake(self.bounds.size.width, CGFLOAT_MAX)

ericbomgardner pushed a commit to quizlet/TTTAttributedLabel that referenced this pull request Jun 8, 2020
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

Successfully merging this pull request may close these issues.

None yet

1 participant