Reputation: 1347
I have a textfield that can switch between a numpad and an alphanumeric keyboard (for design reasons). Here's the code:
self.tfID.keyboardType = UIKeyboardTypeAlphabet;
[self.tfID reloadInputViews];
The problem is that when I switch from numpad to alphanumeric, it doesn't automatically turn on the caps even though that field is set to UITextAutocapitalizationTypeAllCharacters. I don't want to do this through the delegate because I want to still allow the user to enter in lowercase characters if they choose so. Is there a way to do this?
Edit: After the first character is typed, the caps lock is turned back on so only the first character is lowercased.
Upvotes: 0
Views: 231
Reputation: 161
I have tried this and it works. Instead of calling reloadInputViews on your textfield, if you call resignFirstResponder immediately followed by a becomeFirstResponder on your textfield it will auto switch to all caps again for the first character. This does slightly show the animation from lower case keys to all caps keys, but it does achieve your functional goal of getting back to all caps automatically for that first character.
self.tfID.keyboardType = UIKeyboardTypeAlphabet;
[self.tfID resignFirstResponder];
[self.tfID becomeFirstResponder];
Upvotes: 1