I am trying to change the UIKeyboardType to an alphabet keyboard when the user enters a space, reflecting the effect of entering an apostrophe. However, my code will not change the appearance of the keyboard until the user rejects the keyboard and then returns it again.
Edit: To clarify, the keyboard type starts with UIKeyboardTypeNumbersAndPunctuation, and I want to switch to ASCIICapable, because the typical user input is in the form of "flour # cups". I realized that the ASCIICapable keyboard has built-in functionality, so the presentation of an ASCII-compatible keyboard, but showing numbers / punctuation, will work first.
Here is my code:
- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if ([string isEqualToString:@" "]) { textField.keyboardType = UIKeyboardTypeASCIICapable; } return YES; }
ios apostrophe uikeyboardtype
Maxgabriel
source share