UITextView link tap targets are misaligned when hyphenation is enabled

Originator:adamschlag
Number:rdar://23765118 Date Originated:04-Dec-2015
Status:Open Resolved:
Product:iOS Product Version:9.1
Classification:UI/Usability Reproducible:Always
 
Summary:
When setting attributed text on a UITextView tap targets will become misaligned with their associated text when hyphenation is also turned on. It doesn't matter if hyphenation is enabled in an NSParagraphStyle attribute or in the NSLayoutManager associated with the UITextView. The visual styles associated with the text are correct, but when a link is encountered after several lines of hyphenation the touch target to enable the link is aligned several characters before the actual link text.

Steps to Reproduce:
1. Create an app that uses a UITextView
2. Assign an NSAttributedString to the UITextView using -[UITextView setAttributedText]. The string should be hyphenated (using NSParagraphStyle) and also contain links (using NSLinkAttributeName).
3. Run the app
4. Try to tap a link after several lines of hyphenation. The more lines that are hyphenated, the further the tap target will be from the actual link text.

Expected Results:
Tap targets should remain aligned with their associated text.

Actual Results:
Tap targets become misaligned from their associated text, which makes them almost impossible to tap (you have to guess where the tap target is).

Version:
iOS 9.1 [13B143]

Notes:
A sample project is attached that shows the problem. All of the links (look for the word "Space") are misaligned.

Configuration:
iOS Simulator, iPhone 6 Plus 64 GB AT&T (using WiFi)

Attachments:
Project included as zip, also available at https://github.com/adamschlag/LinkBug

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!