iPhone: Issue disabling Auto-Cap/autocorrect on a UITextField

后端 未结 6 1358
抹茶落季
抹茶落季 2020-12-24 10:52

For some reason, even though I disable the auto-cap and auto-correct of my UITextField, it\'s still capitalizing the first letter of my input.

Here is the code:

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 11:31

    Objective - C

    -(void)textFieldDidBeginEditing:(UITextField *)textField
    {
        textField.autocorrectionType = FALSE; // or use  UITextAutocorrectionTypeNo
        textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    
    }
    

    Swift

    func textFieldDidBeginEditing(textfield : UITextField)
    {
        textField.autocorrectionType = .No
        textField.autocapitalizationType = .None
        textField.spellCheckingType = .No
    }
    

    Swift3

      func textFieldDidBeginEditing(_ textField : UITextField)
    {
        textField.autocorrectionType = .no
        textField.autocapitalizationType = .none
        textField.spellCheckingType = .no
    }
    

提交回复
热议问题