0
I am creating a login screen, I want: in case the user has not entered your document (username) the login button is disabled.
import UIKit
class loginManager: UIViewController, UITextFieldDelegate {
@IBOutlet weak var document: UITextField!
@IBOutlet weak var loginButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
document.delegate = self
loginButton.isEnabled = false
}
}
extension ViewController: UITextFieldDelegate {
extension ViewController: UITextFieldDelegate {
func documentDidEndEditing(_ document: UITextField) {
if document.text?.isEmpty == false {
loginButton.isEnabled = true
} else {
loginButton.isEnabled = false
}
}
}
}