Disable autocorrect UITextView

2019-03-01 16:49发布

Does anyone know how to disable autocorrect programming in uitextview? I have the following code, but it doesn't work.

- (void)_setUpTextView {
    self.textView = [[UITextView alloc] initWithFrame:self.bounds];
    self.textView.accessibilityLabel = @"CommentTextView";
    self.textView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.textView setFont:[[AppearanceManager sharedManager] brightenFontWithSize:26.0f]];
    [self.textView.layer setCornerRadius:5.0f];
    self.textView.delegate = self;
    self.textView.autocorrectionType = FALSE; // or use  UITextAutocorrectionTypeNo
    self.textView.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [self addSubview:self.textView];
}

1条回答
倾城 Initia
2楼-- · 2019-03-01 17:00

Whoa there buddy, you commented out your own answer. Make this change:

self.textView.autocorrectionType = UITextAutocorrectionTypeNo;

And you should be good to go. autoCorrectionType does not take a boolean as an argument.

查看更多
登录 后发表回答