mattt/TTTAttributedLabel — pull request #383 by getaaron (2014-05-09 21:03:15+00:00)
Title: Add UIAccessibility support to TTTAttributedLabel links - request for code review

Sight-impaired or other VoiceOver users cannot select links in a `TTTAttributedLabel`. This pull request aims to fix that, and updates the table cells in the demo project to work properly.

This has only been casually tested - I haven't looked for any edge cases yet.

I'm happy to update this pull request in response to any feedback.

Here are some things I'd like feedback on:

> ##### 1. I'm not sure if the `accessibilityValue` logic is ideal
> Currently there is no way for a developer to override the `accessibilityValue` for a link. For URLs, phone numbers and dates, a string is used. For all other types it is left `nil`. This might be bad for developers that use links to non-HTTP resources (like `open-twitter-profile://getaaron`). The shortcoming should be documented, or resolved (perhaps through a delegate method like `accessibilityValueForTextCheckingResult:`), or the `accessibilityValue` logic should be removed altogether.

> ##### 2. It only works on iOS 7
> I'm currently using `NSTextContainer`, `NSLayoutManager`, and `NSTextStorage` to find the frame of the links (See `boundingRectForCharacterRange:`.) These classes are only available on iOS 7. I wrapped the accessibility stuff in `#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000` to avoid crashes, but I'm not enough of a text guru to determine if there's a better way to get the frames on iOS 4 - 6.

> ##### 3. There is some similar code that could be refactored
> The beginning of `boundingRectForCharacterRange:` looks a lot like the beginning of `setText:
afterInheritingLabelAttributesAndConfiguringWithBlock:`; perhaps this should be refactored into a function.