I\'m trying to set the animation for the view to move up when keyboard is hiding and appearing for the text fields and I got it to work perfectly fine, but when the focus moves
In swift 4:
UITextFieldDelegate
into your ViewController
classtextFields
you want to detect focus ontextFieldDidBeginEditing
(in case you want to be notified on that specific action, see Apple's documentation) and fill it with your codeviewDidLoad()
assign your ViewController
class as the delegate for the textField
you previously added in step 2It must look similar to:
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var yourTextField: UITextField!
func textFieldDidBeginEditing(_ textField: UITextField) {
// Your code here
}
override func viewDidLoad() {
super.viewDidLoad()
yourTextField.delegate = self
}
...
}