【发布时间】:2015-08-05 01:09:01
【问题描述】:
textFieldShouldReturn 函数根本没有被调用:没有错误但键盘根本没有响应。
我的情况与 How to hide keyboard in swift on pressing return key? 不同,因为在我的情况下什么都没有发生,而其他情况在 Objective-C 中。
这是我的代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet var textField: UITextField!
func textFieldShouldReturn(textField: UITextField) -> Bool {
resignFirstResponder()
return true
}
}
textField 是我故事板上文本字段的一个出口。我也试过self.endEditing而不是resignFirstResponder。
【问题讨论】: