iOS 8 Keyboard Dismissed delay after modal view controller is dismissed

前端 未结 2 570
囚心锁ツ
囚心锁ツ 2021-01-11 13:02

In iOS 8+ I noticed that if you have an textfield that is currently the firstResponder in a view controller that was presented, when the view controller is dism

2条回答
  •  攒了一身酷
    2021-01-11 13:41

    For Swift 3/4

    override func viewWillDisappear(_ animated: Bool) {
        self.view.endEditing(true)
    }
    

    Also if it's not resigning try calling resignFirstResponder on the text field you're trying to end typing on.

    override func viewWillDisappear(_ animated: Bool) {
        textField.resignFirstResponder()
    }
    

提交回复
热议问题