First letter in UiTextField lowercase

IphoneObjective CUitextfield

Iphone Problem Overview


How do you make it so that when you start typing on the keyboard after youve clicked on a UITextfield the first letter isn't a capital automatically?

Iphone Solutions


Solution 1 - Iphone

In Objective-C:

textField.autocapitalizationType = UITextAutocapitalizationTypeNone;

In Swift:

textField.autocapitalizationType = .none

Solution 2 - Iphone

You can turn off auto-capitalization with the .autocapitalizationType property in the UITextInputTraits protocol.

textfield.autocapitalizationType = UITextAutocapitalizationTypeNone;

Solution 3 - Iphone

For SwiftUI,

TextField("I want entered text to be all lowercase", text:$myText)
     .autocapitalization(.none)

Solution 4 - Iphone

You can set capitalization for TextField in the Text Input Traits of Text Field Attributes in XIB(interface Builder).

Solution 5 - Iphone

set setAutocapitalizationType:UITextAutocapitalizationTypeNone for UITextField.

Solution 6 - Iphone

In Swift:

textField.autocapitalizationType = UITextAutocapitalizationType.None

Solution 7 - Iphone

In Swift you can use the autocapitalizationType property:

yourTextField.autocapitalizationType = .none

Solution 8 - Iphone

To avoid completely there are three properties that we can set

textField.autocapitalizationType = .none;

and

textfield.autocorrectionType = .no;

and

textField.spellCheckingType = .no

Only setting .autocapitalizationType = .none; works but better we set other both the properties to avoid capitalising from autocorrection and spell checking.

Solution 9 - Iphone

Try this code:

textfieldname.autocapitalizationType = UITextAutocapitalizationTypeNone;

Solution 10 - Iphone

this code will lowercase all the text field input when you type any thing in your targeted text Field

func textField(_ textFieldToChange: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
         //just change this charectar username  it's a text field
        if textFieldToChange == username {
            let characterSetNotAllowed = CharacterSet.whitespaces
            if let _ = string.rangeOfCharacter(from:NSCharacterSet.uppercaseLetters) {
                return false
            }
            if let _ = string.rangeOfCharacter(from: characterSetNotAllowed, options: .caseInsensitive) {
                return false
            } else {
                return true
            }
        }
        return true
    }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondaihoveyView Question on Stackoverflow
Solution 1 - IphoneySgPjxView Answer on Stackoverflow
Solution 2 - IphonekennytmView Answer on Stackoverflow
Solution 3 - IphoneSnipsView Answer on Stackoverflow
Solution 4 - IphoneShashankView Answer on Stackoverflow
Solution 5 - IphonesaadnibView Answer on Stackoverflow
Solution 6 - IphoneKing-WizardView Answer on Stackoverflow
Solution 7 - IphoneWilliam HuView Answer on Stackoverflow
Solution 8 - Iphonenikhilgohil11View Answer on Stackoverflow
Solution 9 - Iphonehardik hadwaniView Answer on Stackoverflow
Solution 10 - IphonemazenqpView Answer on Stackoverflow