UITextView don't call "shouldInteractWith textAttachment" when tapping attachment on iOS 13.2

After updating to iOS 13.2, tapping on the attachment on the text view will not call this delegate method at all.


func textView(_ textView: UITextView,
                  shouldInteractWith textAttachment: NSTextAttachment,
                  in characterRange: NSRange,
                  interaction: UITextItemInteraction) -> Bool


Long pressing on the attachment will call this delegate method instead. I'm wondering It's a bug or intended change.


Any help is welcome.

Replies

tapping on the attachment on the text view will not call the delegate method at all.

Which delegate function do you expect to be called ?


Long pressing on the attachment will call this delegate instead

Do you mean textView(_:shouldInteractWith:in:interaction:)


Which version of XCode ?

There were issues with UITextView in 11.2, maybe you could try with 11.2.1 GM Seed.

1.

The delegate function expected to be called when tapping on attachment is:

func textView(_ textView: UITextView,  
                  shouldInteractWith textAttachment: NSTextAttachment,  
                  in characterRange: NSRange,  
                  interaction: UITextItemInteraction) -> Bool 

2. Yes

3. I think it's an issue with iOS, not the Xcode. The app store release version app was build using Xcode 11.1 which works as expected before iOS 13.2. After upgrading to iOS 13.2, the problem happened with the same build.

It seems there was an issue with this func in iOS 13.1

https://stackoverflow.com/questions/58189447/ios-13-1-uitextview-delegate-method-shouldinteract-called-when-scrolling-on-atta


APparently, they have changed it in 13.2, but that had the side effect you see.

Did you have some special code to make it work correctly on 13.1 ?

In fact, this StackOverflow question was also posted by me. This question is primary about interacting with the link, and attachment has a similar issue.


I did add some code `textView(_:shouldInteractWith:in:interaction:)` to make tapping on attachment works on iOS 13.1. Apple did fix the issue mentioned in the StackOverflow question in iOS 13.2 but also introduced a new bug that only long pressing on attachment called the delegate method.

😁 So I gave you the time on your own watch. I should become consultant. 😁


Seriously, did you file a bug ?

I appreciate your time and effort. Thanks!

I did file a bug via the Feedback Assistant. The bug ID is FB7435357.

I will try to replicate the bug with a small project and will report.

Hi,
having the same issue for me it does't for iOS 13.2.x but it also doesn't work for 13.1.x the callback function gets called but not only for taps also when you scroll a textview.


Can somebody at Apple take a look at this? it offers a very bad user experience for our app.


Thanks