简体   繁体   English

使用Interface Builder在UITextField上关闭键盘

[英]Dismiss keyboard on UITextField using Interface Builder

I've seen this, but don't remember what Jedi technique exactly was used through interface builder to dismiss uikeboard when return key is pressed. 我已经看到了这一点,但是不记得在按下返回键时,通过界面构建​​器正确使用了什么Jedi技术来解除uikeboard。 Anyone knows how to do this? 谁知道怎么做?

Please do not post about using UITextFieldDelegate, I know that method, I'm only interested in forcing keyboard to be dismissed on return key being hit without any additional logic or protocol conformation. 请不要发布关于使用UITextFieldDelegate的信息,我知道这个方法,我只对强制键盘在返回键被击中而没有任何额外的逻辑或协议构造感到兴趣。

Connect the IBAction with "Did End On Exit" event in your xib of your textfield 将IBAction与文本域的xib中的“退出时结束”事件相关联

-(IBAction)textFieldDidEndOnExit:(UITextField *)sender
{

}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

    if let touch = touches.first{
        view.endEditing(true)
       }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM