hide keyboard for text field in swift programming language

后端 未结 14 1077
不思量自难忘°
不思量自难忘° 2020-11-27 17:07

I have little experience in Objective-C. I want to hide the keyboard for a text field using the Swift programming language.

I also tried this

func te         


        
14条回答
  •  余生分开走
    2020-11-27 17:29

    In simple way to hide the keyboard just override the UIView "touchBegan method". So when you tap any where in the view keyboard is hide. here is the sample code.. (Swift 3.0 Updated code)

    override func touchesBegan(_ touches: Set, with event: UIEvent?) 
    {
       self.view.endEditing(true)
    }
    

提交回复
热议问题