我已經看過計算器上幾個其他的答案,但我似乎無法將它們應用到我的代碼:如何在按下回車鍵和/或在鍵盤區外部按鍵後使鍵盤退出?
import UIKit
class GraphItemCell: UITableViewCell, UITextFieldDelegate {
@IBOutlet weak var itemNameLabel: UITextField?
@IBOutlet weak var itemDescriptionLabel: UITextField?
@IBOutlet weak var pointScore: UITextField?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func layoutSubviews() {
super.layoutSubviews()
}
//TextField delegate
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
return false
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
我用了一個tapgesture識別並沒有把resignFirstResponder在那裏 – StealthOne