Disabling user input for UITextfield in swift

Matt Spoon picture Matt Spoon · Apr 22, 2015 · Viewed 106.2k times · Source

pretty trivial question, I know. But I can not find anything online.

I need to disable the user from being able to edit the text inside of a text field. So that when the click on the text, a keyboard doesn't show up.

Any ideas?

A programmatic solution or if it is possible through storyboards would be great.

Answer

Vlad picture Vlad · Apr 22, 2015

Try this:

Swift 2.0:

textField.userInteractionEnabled = false

Swift 3.0:

textField.isUserInteractionEnabled = false

Or in storyboard uncheck "User Interaction Enabled"

enter image description here