How to open the keyboard automatically on UITextField?

前端 未结 4 2047
借酒劲吻你
借酒劲吻你 2021-01-30 06:27

I have a very simple table and when tocuh a cell it opens a new view with one UITextfield. All I want is that the keyboard will automatically opens, without the user have to tou

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 06:58

    Swift 3 & 4:

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        textField.becomeFirstResponder()
    }
    

提交回复
热议问题