Search code examples
iosswiftuitextfieldediting

Disabling user input for UITextfield in swift


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.


Solution

  • 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