I have a UITableViewCell and in it there is a reference to a UITextField:
@IBOutlet weak var inputTextSelectAnswer: UITextField!
i'm trying to add a "Done" button ontop of the keyboard and while u tap it the keyboard will be closed >
func setDoneOnKeyboard() {
let keyboardToolbar = UIToolbar()
keyboardToolbar.sizeToFit()
let flexBarButton = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneBarButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismissKeyboard))
keyboardToolbar.items = [flexBarButton, doneBarButton]
self.inputTextSelectAnswer.inputAccessoryView = keyboardToolbar
}
since i don't call the UITextField in my controller itself, but in my UITableViewCell is there a way to dismiss the keyboard it throws an error
Use of unresolved identifier 'view'
here is the code:
//CANNOT DO THE FUNCTION BELOW
@objc override func dismissKeyboard() {
view.endEditing(true)
}
how can this be done from a UITableViewCell ?