Search code examples
objective-cuitextviewautocorrect

Disable autocorrect UITextView


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];
}

Solution

  • 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.