Попробуйте именовать текстовые поля последовательно txt1 txt2 txt3 txt4 tt5 txt6
override func viewDidLoad() {
super.viewDidLoad()
txt1.becomeFirstResponder()
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if ((textField.text?.count)! < 1 ) && (string.count > 0) {
if textField == txt1 {
txt2.becomeFirstResponder()
}
if textField == txt2 {
txt3.becomeFirstResponder()
}
if textField == txt3 {
txt4.becomeFirstResponder()
}
if textField == txt4 {
txt5.becomeFirstResponder()
}
if textField == txt5 {
txt6.becomeFirstResponder()
}
if textField == txt6{
txt6.becomeFirstResponder()
}
textField.text = string
return false
} else if ((textField.text?.count)! >= 1) && (string.count == 0) {
if textField == txt2 {
txt1.becomeFirstResponder()
}
if textField == txt3 {
txt2.becomeFirstResponder()
}
if textField == txt4 {
txt3.becomeFirstResponder()
}
if textField == txt5 {
txt4.becomeFirstResponder()
}
if textField == txt6 {
txt5.becomeFirstResponder()
}
if textField == txt1{
txt6.resignFirstResponder()
}
textField.text = ""
return false
} else if (textField.text?.count)! >= 1 {
textField.text = string
return false
}
return true
}
Happy Coding