當畫面一連串輸入欄位時, apple在按下Enter鍵後並不會自動跳往下一個輸入欄位, 要達成此機制則需進行 UITextFieldDelegate 事件處理.
輸入欄位順序處理@IBOutlet var Login: UITextField! @IBOutlet var Password: UITextField! override func viewDidLoad() { super.viewDidLoad(); //登錄 Login.delegate = self; Password.delegate = self; }
//指向下一個 焦點 func textFieldShouldReturn(_ textField: UITextField) -> Bool {//delegate method if (textField == Login) { textField.resignFirstResponder(); Password.becomeFirstResponder(); } else if (textField == Password) { textField.resignFirstResponder(); } return true }