Skip to content

Instantly share code, notes, and snippets.

@groue
Last active March 30, 2016 06:35
Show Gist options
  • Select an option

  • Save groue/29f2aec9ec386ab9f6acfcc8fcc2a23e to your computer and use it in GitHub Desktop.

Select an option

Save groue/29f2aec9ec386ab9f6acfcc8fcc2a23e to your computer and use it in GitHub Desktop.
// MARK: - Form
extension PersonEditionViewController: UITextFieldDelegate {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
nameTextField.becomeFirstResponder()
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: false)
let cell = tableView.cellForRowAtIndexPath(indexPath)
if cell === nameCell {
nameTextField.becomeFirstResponder()
} else if cell === scoreCell {
scoreTextField.becomeFirstResponder()
}
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
if textField == nameTextField {
scoreTextField.becomeFirstResponder()
}
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment