Disable startup on a global scale in the application

I would like to turn off the auto-input of text input in the iPad application, regardless of what global settings for auto-replace are on the device. Is there a good way to do this through the API, or do I just need to go through the entire application, find all the text input fields and disable the option for each field separately?

+1
source share
4 answers

I'm sorry, but you need to go through all the text fields and turn it off

+3
source

You can override the default text field auto-correction type using the swizzling method. In the application delegate or somewhere else sensible:

#import <objc/runtime.h> // Prevent this code from being called multiple times static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ struct objc_method_description autocorrectionTypeMethodDescription = protocol_getMethodDescription(@protocol(UITextInputTraits), @selector(autocorrectionType), NO, YES); // (Re)implement `-[UITextField autocorrectionType]` to return `UITextAutocorrectionTypeNO`. IMP noAutocorrectionTypeIMP = imp_implementationWithBlock(^(UITextField *_self){ return UITextAutocorrectionTypeNo; }); class_replaceMethod([UITextField class], @selector(autocorrectionType), noAutocorrectionTypeIMP, autocorrectionTypeMethodDescription.types); }); 
+2
source

Perhaps you can subclass UITextField and set the desired properties for it. Instead of a UITextField, you can use this subclass.

This may be worthy if you have not started to implement the application!

+1
source

like @cocoakomali , you can create a UITextField category to disable autocorrect for all UITextField in the default application

 @implementation UITextField (DisableAutoCorrect) - (instancetype)init { self = [super init]; if (self) { [self setAutocorrectionType:UITextAutocorrectionTypeNo]; } return self; } @end 
0
source

All Articles