Dismissing the keyboard when a button is pressed, programmatically with swift?

后端 未结 4 1498
北恋
北恋 2021-02-15 00:07

How can I dismiss the keyboard when a button is pressed, programmatically with swift?

4条回答
  •  终归单人心
    2021-02-15 00:22

    There is also the so called "big hammer".

    Just call self.view.endEditing(true)

    The documentation states the following for this method:

    Causes the view (or one of its embedded text fields) to resign the first responder status.

提交回复
热议问题