Disabling user input for UITextfield in swift

后端 未结 8 720
半阙折子戏
半阙折子戏 2021-02-01 11:55

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

相关标签:
8条回答
  • 2021-02-01 12:48

    If you want to do it while keeping the user interaction on. In my case I am using (or rather misusing) isFocused

    self.myField.inputView = UIView()
    

    This way it will focus but keyboard won't show up.

    0 讨论(0)
  • 2021-02-01 12:49

    In swift 5, I used following code to disable the textfield

    override func viewDidLoad() {
       super.viewDidLoad()
       self.textfield.isEnabled = false
       //e.g
       self.design.isEnabled = false
    }
    
    0 讨论(0)
提交回复
热议问题