Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you programmatically accept a spelling correction in UITextView?

I have a button that inserts a character into a UITextView. I want this button to behave as the spacebar button does; I want the pending autocorrect suggestion to be accepted upon pressing it.

Can this be done? If so, how? Thanks!

like image 627
strawtarget Avatar asked Oct 11 '10 21:10

strawtarget


2 Answers

I just found out that instead of doing this (kills my animations) you can use:

  [messageField reloadInputViews];

Works like a charm.

like image 199
agfa555 Avatar answered Oct 22 '22 17:10

agfa555


There isn't any API to interact directly with autocorrect. However, there is a bit of a hack I ran across not long ago: if you resign the responder, the currently displayed autocorrect will be accepted. So, you may be able to get away with resigning the first responder and then assigning it again:

[myTextView resignFirstResponder];
[myTextView becomeFirstResponder];
like image 25
memmons Avatar answered Oct 22 '22 17:10

memmons