UITextViewDelegate's textView(_:shouldInteractWithURL:inRange:) does not contain enough information

Originator:jason.sadler
Number:rdar://26781880 Date Originated:13/06/2016
Status:Open Resolved:
Product:iOS SDK Product Version:7.0 and later
Classification: Reproducible:Always
 
Summary:
The discussion in the documentation states that this delegate method is called for taps *and* long-presses, and "...you can use this method to trigger an alternative action, such as displaying the web content at the URL in a web view within the current application."

However this method does not provide information on what kind of interaction (tap/long-press) is being represented. In the documented example, I would want to present a Safari View Controller on tap, but defer to default behaviour on long-press. Current method signature does not contain enough information to distinguish between these two cases.

Steps to Reproduce:
1. Create a simple UI with a UITextView
2. Configure text view with appropriate data detectors, set it to selectable, and non-editable
3. Fill the UITextView with a string that contains links, phone numbers, etc
4. Create a delegate that implements textView(_:shouldInteractWithURL:inRange:) and presents a Safari View Controller if URL's scheme is http / https, returning false, or doing nothing and returning true if the scheme is something else
5. Launch app and long-press on an HTTP link

Expected Results:
textView(_:shouldInteractWithURL:inRange:) is invoked, but should include additional information so that the implementation knows whether this is a tap (continue by presenting opening Safari View Controller) or a long-press (return true to defer to default behaviour)

Actual Results:
textView(_:shouldInteractWithURL:inRange:) is invoked and Safari View Controller is presented

Version:
iOS 7.0 and later

Notes:


Configuration:
Any

Attachments:

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!