I would like to disable text-entry autocorrect in an iPad application, regardless of what the global settings for autocorrect are on the device. Is there a good way to do this t
You can override the default text field autocorrection type with a bit of method swizzling. In your app delegate or somewhere else sensible:
#import
// 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);
});