Reputation: 17902
I would like to turn my user's keyboard from uppercase to lowercase to force typing in lower-case. How can I do this?
Upvotes: 5
Views: 5676
Reputation: 709
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
Upvotes: 3
Reputation: 385920
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.
Upvotes: 6
Reputation: 5745
What you can do is make the string of the text box lowercase after they close the keyboard. For example,
[sender resignFirstResponder];
textField.text = textField.text.lowercaseString;
This makes the text lowercase when they close the keyboard, which does what you want.
Upvotes: 2