Created
September 29, 2015 04:55
-
-
Save joshsmith/5b705cece6547879f49e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func textFieldDidBeginEditing(textField: UITextField) { | |
print(textField.tag) | |
switch textField.tag { | |
case 0: | |
if textField.text == "First name" { textField.text = nil } | |
case 1: | |
if textField.text == "Last name" { textField.text = nil } | |
default: | |
textField.text = nil | |
} | |
} | |
func textFieldDidEndEditing(textField: UITextField) { | |
switch textField.tag { | |
case 0: | |
if textField.text == "" { | |
textField.text = "First name" | |
} | |
case 1: | |
if textField.text == "" { | |
textField.text = "Last name" | |
} | |
default: | |
return | |
} | |
} | |
func textFieldShouldReturn(textField: UITextField) -> Bool { | |
switch textField { | |
case firstNameField: | |
return lastNameField.becomeFirstResponder() | |
case lastNameField: | |
return lastNameField.resignFirstResponder() | |
default: | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment