How to dismiss number pad keyboard by tapping anywhere

后端 未结 15 2199
梦如初夏
梦如初夏 2020-12-04 17:53

I\'d like to know the simplest code to dismiss the number pad keyboard when tapping anywhere outside the number pad. It\'s a simple application to input a number inside a te

15条回答
  •  醉话见心
    2020-12-04 18:18

    For Swift, the easiest for dismissing keypad for all text fields by tapping anywhere outside the text field is:

    override func touchesBegan(touches: NSSet, withEvent event: UIEvent)
    {
        self.view.endEditing(true)
    }
    

提交回复
热议问题