How to toggle autocorrectionType on and off for an existing UITextView

前端 未结 4 847
一个人的身影
一个人的身影 2020-12-30 02:42

I have a UITextView in my iPhone app for which I want to be able to toggle the autocorrectionType.

When a user is editing the text view, I want the autocorrectionTy

4条回答
  •  时光取名叫无心
    2020-12-30 03:00

    Here's an easy way to do this for the image export scenario :

    - (BOOL)textViewShouldBeginEditing:(UITextView *)textView
    {
        // Turn spell check on
        textView.autocorrectionType = UITextAutocorrectionTypeYes;
        return YES;
    }
    
    
    - (BOOL)textViewShouldEndEditing:(UITextView *)textView
    {
        // Turn spell check off and clean up red squiggles.
        textView.autocorrectionType = UITextAutocorrectionTypeNo;
        NSString *currentText = textView.text;
        textView.text = @"";
        textView.text = currentText;
        return YES;
    }
    

提交回复
热议问题