I would like to turn my user's keyboard from uppercase to lowercase to force typing in lower-case. How can I do this?
Instead of trying to force the keyboard into lower-case, just force the characters to lower-case after the user types them.
You didn't say whether you're using a UITextField
or a UITextView
. Let's suppose you're using a UITextField
.
Declare your view controller to adopt the UITextFieldDelegate
protocol, and set the delegate of the text field to the view controller.
In the view controller, implement this method:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
string = [string lowercaseString];
textField.text = [textField.text stringByReplacingCharactersInRange:range
withString:string];
return NO;
}
If you are using a UITextView
, adopt the UITextViewDelegate
protocol and implement the textView:shouldChangeTextInRange:replacementText:
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With