- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == userName) {
[userName resignFirstResponder];
[userPassword becomeFirstResponder];
}
if (theTextField == userPassword) {
[userPassword resignFirstResponder];
[serverAddress becomeFirstResponder];
}
if (theTextField == serverAddress) {
[serverAddress resignFirstResponder];
}
return YES;
}
Ok, I wrote the if statements before I even finished writing this blog. It's messy, so if you know a bette/faster way to do this, do it your way!
- (BOOL)textFieldShouldReturn:(UITextField *)aTextField {
if (aTextField == userName) {
[userName resignFirstResponder];
if ([userPassword.text length] == 0) {
[userPassword becomeFirstResponder];
} else if ([serverAddress.text length] == 0) {
[serverAddress becomeFirstResponder];
}
}
if (aTextField == userPassword) {
[userPassword resignFirstResponder];
if ([serverAddress.text length] == 0) {
[serverAddress becomeFirstResponder];
}
}
if (aTextField == serverAddress) {
[serverAddress resignFirstResponder];
}
return YES;
}
No comments:
Post a Comment