UITextView Disable selection, allow links
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
UITextView has an awkward default for read-only text that contains links. If you leave selection enabled, users can long-press, select text, and see edit actions. If you disable selection entirely, link taps stop working. The practical solution is to keep the text view non-editable, keep it selectable for link interaction, and then block the selection behavior you do not want.
Start with the Right Base Configuration
Link interaction in UITextView depends on isSelectable, so the baseline configuration matters:
- '
isEditable = false' - '
isSelectable = true' - attributed text or data detectors for the links
- a delegate if you want to intercept taps
At this point, links are tappable, but users can still trigger selection.
Suppress Selection Without Breaking Links
One small subclass is usually enough. The goal is not to disable every gesture. The goal is to neutralize selection-related behavior while leaving tap handling intact.
That approach preserves ordinary taps, including taps on attributed links, while removing the usual long-press selection path. It is intentionally small, which makes it easier to revisit if iOS gesture internals change.
Route Link Taps Through the Delegate
Even if the default browser behavior is acceptable, it is usually worth handling link taps yourself. That gives you one place for validation, analytics, or in-app navigation.
Returning false tells the text view that you handled the tap. If you want the system default behavior instead, return true.
Accessibility and Layout Still Matter
Disabling selection should not make the content harder to use. Link styling needs to stay legible, Dynamic Type should still work, and VoiceOver users should still be able to navigate to the links.
Two practical habits help here:
- keep the text concise enough that each link has a clear label
- test on a real device, because long-press timing and interaction details are easier to judge there than in the simulator
If the screen is just a legal disclaimer or rich help text, you may also consider UILabel plus a custom interaction layer or a web view. UITextView is the best fit when you want rich attributed text, scrolling, and built-in link handling.
Common Pitfalls
- Setting
isSelectabletofalse, which disables link interaction along with text selection. - Disabling every gesture recognizer and accidentally breaking scrolling or normal taps.
- Forgetting to assign the delegate, so custom link routing never runs.
- Testing only in the simulator and missing a device-specific interaction issue.
- Removing selection in a way that harms accessibility without rechecking VoiceOver behavior.
Summary
- Keep the text view non-editable but selectable so links remain tappable.
- Use attributed links or detectors, then suppress selection behavior in a subclass.
- Override only the parts of interaction you need to change.
- Handle URLs in the delegate if you want custom navigation logic.
- Recheck scrolling, real-device gestures, and accessibility after the change.

