I have a UITextView
that displays an NSAttributedString
that contains various links (via NSLinkAttributeName
) and I want to be able to use my own view controllers as the previewing and commit view controllers rather than the default behaviour.
I assume that this is possible because the UITextItemInteraction
enum, which is used in UITextViewDelegate
, contains a case for 3D touching.
I have tried:
looking for a solution in
UITextViewDelegate
but the closest function to what I want,textView(_:shouldInteractWith:in:interaction:)
doesn't seem to let you change the preview or commit view controllers - just disable the default behaviourdoing it the same way as you would with any other view and registering it for 3D touch and using
previewingContext(_:viewControllerForLocation:)
fromUIViewControllerPreviewingDelegate
, but I cant find a way to get the link that has been 3D touched
Could someone please let me know the proper way to do this?