I am building an app that contains a search or a UITextField and it is located at the bottom of the view near the safe area, so when I touch it and the keyboard pops up, the textfield gets hidden behind the keyboard.
How can I make it so when the keyboard pops up the Textfield moves right above it? Here is the code I have in the viewController.swift
class ViewController: UIViewController {
@IBOutlet weak var windLabel: UILabel!
@IBOutlet weak var cityLabel: UILabel!
@IBOutlet weak var tempLabel: UILabel!
@IBOutlet weak var searchCItyTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
searchCItyTextField.delegate = self
}
}
//MARK: - UITextFieldDelegate
extension UIViewController: UITextFieldDelegate {
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.view.endEditing(true)
return true
}
}