Reputation: 609
func textFieldDidBeginEditing(textField: UITextField) {
scrlView.setContentOffset(CGPointMake(0, textField.frame.origin.y-70), animated: true)
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
textField.resignFirstResponder()
scrlView .setContentOffset(CGPointMake(0, 0), animated: true)
return true
}
How can I move cursor from one textfield to another automatically after entering value in the first textfield?
Upvotes: 0
Views: 1329
Reputation: 8049
first, you need add tags to your text fields orderly
func textFieldShouldReturn(textField: UITextField) -> Bool {
let nextTag = textField.tag + 1;
// Try to find next responder
var nextResponderTxt: UITextField!
nextResponderTxt = textField.superview?.viewWithTag(nextTag) as? UITextField
if ((nextResponderTxt) != nil) {
// Found next responder, so set it.
nextResponderTxt.becomeFirstResponder()
} else {
// Not found, so remove keyboard.
textField.resignFirstResponder()
}
return false; // We do not want UITextField to insert line-breaks.
}
Also you can change the return key to next
Upvotes: 2