Here's what worked for me.
I couldn't get rid of the magnify glass, but this will allow you to keep the text view selectable (so you can tap the links), but get rid of all the selection related UI. Only tested on iOS 9.
Caution Swift below!
First, subclass UITextView
and include this function:
override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
return false
}
That will disable the copy, etc menu. I then include a setup method, which I call from init, where I do a bunch of setup related tasks. (I only use these text views from a storyboard, thus the decoder init):
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
private func setup() {
selectable = true
editable = false
tintColor = UIColor.clearColor()
}
Selectable = true to keep the links tappable, editable = false because links aren't tappable in an editable text view. Specifying a clear tintColor
hides the blue bars that appear at the beginning and end of a selection.
Lastly, in the controller that is using the subclassed text view, make sure the UITextViewDelegate
protocol is included, that the delegate is set textView.delegate = self
, and implement this delegate function:
func textViewDidChangeSelection(textView: UITextView) {
var range = NSRange()
range.location = 0
range.length = 0
textView.selectedRange = range
}
Without this function, the selection bars, and contextual menu will be disabled, but a colored background will still be left behind the text you selected. This function gets rid of that selection background.
Like I said, I haven't found a way to get rid of the magnify glass, but if they do a long tap anywhere besides a link, nothing will be left behind once the magnify glass disappears.