Textfield next option to focus on next textfield in tableview iOS swift
Problem:
I'm having tableview with multiple cells with multiple textfields.I'm having next button option for all textfields and end of textfield will have done option with that.
While user click on next we want to focus the next textfield in the tableview.
How to achieve that?
Solution:
First you have to assign row index as tag to the tableview textfield.Then use the below code to achieve that.
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if let nextField = textField.superview?.viewWithTag(textField.tag + 1) as? UITextField {
nextField.becomeFirstResponder()
} else { // for end textfield
textField.resignFirstResponder()
}
return false
}
Comments
Post a Comment