Ios 使用潜意识禁用自动更正
我在潜意识测试中遇到了一些问题,由于设备默认设置,文本会自动更正 有没有一种方法可以让我使用潜意识禁用整个设备上的自动更正?Ios 使用潜意识禁用自动更正,ios,testing,autocorrect,subliminal,Ios,Testing,Autocorrect,Subliminal,我在潜意识测试中遇到了一些问题,由于设备默认设置,文本会自动更正 有没有一种方法可以让我使用潜意识禁用整个设备上的自动更正? 我可以导航到设备设置吗?Subliminal无法导航到设备设置,但您的测试可以使用以下内容覆盖默认的文本字段自动更正类型: // In the test that exercises the text fields, // or a base test class of multiple tests that exercise text fields #import &l
我可以导航到设备设置吗?Subliminal无法导航到设备设置,但您的测试可以使用以下内容覆盖默认的文本字段自动更正类型:
// In the test that exercises the text fields,
// or a base test class of multiple tests that exercise text fields
#import <objc/runtime.h>
- (void)setUpTest {
// `dispatch_once` in case this is a base test class,
// where this method would be 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);
});
}