Reputation:
I have a UITextView for which I want to be able to toggle the autocorrectionType.
Simply toggling the autocorrectionType like this does not work.
myTextView.autocorrectionType = UITextAutocorrectionTypeYes;
myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
I've used
myTextView.text = myTextView.text;
and
[myTextView insertText:@" "];
[myTextView deleteBackward];
and
[myTextView setNeedsDisplay];
None of these work...
Upvotes: 2
Views: 1193
Reputation: 41632
When you change such properties (including the type of keyboard), you often have to "kick start" the process
// Original
myTextView.autocorrectionType = UITextAutocorrectionTypeYes;
... // time goes by
// Now want to change
myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
BOOL bogusKeyboardMotion = YES; // ivar
[myTextView resignFirstResponder];
[myTextView becomeFirstResponder];
bogusKeyboardMotion= NO;
Then ignore any delegate messages in your delegate methods. Maybe setting the delegate to nil then setting it back works too.
Upvotes: 1