Disable UITextField Auto Correction

When I try to edit texts in the iPhone application ( UITextfield ), it automatically corrects my data.

Could you tell me how can I disable this?

+60
ios objective-c uitextfield
May 05 '09 at 23:02
source share
6 answers
 UITextField* f = [[UITextField alloc] init]; f.autocorrectionType = UITextAutocorrectionTypeNo; 
+133
May 05 '09 at 23:11
source share

Quick version

I landed here to find the Swift version:

 myInput.autocorrectionType = .No 

Also read @MaikelS answer

Swift 3.0

 textField.autocorrectionType = .no 
+18
May 14, '15 at 23:40
source share

To achieve this, you can use the UITextInputTraits protocol:

 myInput.autoCorrectionType = UITextAutocorrectionTypeNo; 

See here for more details.

+13
May 05 '09 at 23:10
source share

The Builder interface also has a drop-down box to disable this. Since you are most likely to create text fields in the interface builder, find it there. You can find it in the Attributes Inspector next to Correction.

+9
Aug 30 '11 at 7:30
source share

you can also set this in the storyboard by selecting "attribute inspectors" and in the "Correction" section you can choose: "Default", "Yes" and "No", enter image description here enter image description here

+3
Dec 29 '15 at 16:42
source share
 + (void)disableAutoCorrectionsForTextfieldsAndTextViewGlobally { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ struct objc_method_description autocorrectionTypeMethodDescription = protocol_getMethodDescription(@protocol(UITextInputTraits), @selector(autocorrectionType), NO, YES); IMP noAutocorrectionTypeIMP_TEXT_FIELD = imp_implementationWithBlock(^(UITextField *_self) { return UITextAutocorrectionTypeNo; }); IMP noAutocorrectionTypeIMP_TEXT_VIEW = imp_implementationWithBlock(^(UITextView *_self) { return UITextAutocorrectionTypeNo; }); class_replaceMethod([UITextField class], @selector(autocorrectionType), noAutocorrectionTypeIMP_TEXT_FIELD, autocorrectionTypeMethodDescription.types); class_replaceMethod([UITextView class], @selector(autocorrectionType), noAutocorrectionTypeIMP_TEXT_VIEW, autocorrectionTypeMethodDescription.types); }); } 
+2
Sep 10 '15 at 7:14
source share



All Articles