iPhone Programming: Deactivate spell check in UITextView

后端 未结 4 1182
野趣味
野趣味 2020-12-17 20:48

UITextAutocorrectionTypeNo didn\'t work for me.

I\'m working on a crossword app for the iPhone. The questions are in UITextViews and I use UITextFields for the User-

4条回答
  •  囚心锁ツ
    2020-12-17 21:19

    One potentially-helpful tip following from Engin Kurutepe's answer:

    If you have subclassed UITextView, you can override the UITextInputTraits in the subclass implementation of becomeFirstResponder, something like this:

    -(BOOL)becomeFirstResponder {
        self.spellCheckingType = UITextSpellCheckingTypeNo;
        self.autocorrectionType = UITextAutocorrectionTypeNo;
        self.autocapitalizationType = UITextAutocapitalizationTypeNone;
        return [super becomeFirstResponder];
    }
    

    There is then no need to explicitly resign/becomeFirstResponder around your trait changes.

提交回复
热议问题