Hiya!
I want to change the UITextInputTraits of a keyboard while it is in use....
My ideal code would look something like this:
- (IBAction)nameTextDidChange:(UITextField *)sender {
if ([sender.text isEqualToString:@""]) {
sender.returnKeyType = UIReturnKeyDone;
} else {
sender.returnKeyType = UIReturnKeySearch;
}
}
So... I have a different 'Return' button for an empty string as I do a string with some text in. The code I posted above doesn't work, the keyboard retains it's original text input traits.
Any ideas anyone, or is this never going to work no-matter how hard I try?
Cheers!
Nick.
Thanks to Deepak, this is the code I actually used:
if ([sender.text isEqualToString:@""]) {
sender.returnKeyType = UIReturnKeyDone;
[sender resignFirstResponder];
[sender becomeFirstResponder];
} else if (sender.returnKeyType == UIReturnKeyDone) {
NSString *cachedLetter = sender.text;
sender.returnKeyType = UIReturnKeySearch;
[sender resignFirstResponder];
[sender becomeFirstResponder];
sender.text = cachedLetter;
}