How to toggle autocorrectionType on and off for an existing UITextView

前端 未结 4 844
一个人的身影
一个人的身影 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:19

    You can try to first hide the keyboard first and then displaying it again. Also update the uitextview. If [UITextView setNeedsDisplay] doesn't work for you, try [UITextView insertText:] and then [UITextView deleteBackward]

    [textView resignFirstResponde];
    textView.autocorrectionType = UITextAutocorrectionTypeNo;
    [textView becomeFirstResponder];
    [textView setNeedsDisplay];
    

    or

    [textView insertText:@" "];
    [textView deleteBackward];
    

提交回复
热议问题