Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have two buttons leftBtn and rightBtn respectively, and one UITextField.

When user taps on leftBtn, I have code below,

 [textField resignFirstResponder];
 textField.autocorrectionType = UITextAutocorrectionTypeNo;

when user taps on rightBtn, I have following code,

[textField resignFirstResponder];
textField.autocorrectionType = UITextAutocorrectionTypeYes;

So when right button is tapped I see autocorrect and when left button is tapped I don't see autocorrect.

It works fine but when from right button I pick text from autocorrect and then if I switch to left button it shows keyboard with autocorrect until I have autocorrect text entered in my textfield.

It bypass the line

textfield.autocorrectionType = UITextAutocorrectionTypeYes;

But doesn't hide autocorrect until I remove character entered.

What you are asking exactly ? can't understand because your code seems perfect. when you click right btn it will show autocorrection and when left then it will hide. nothing wrong in it i think – Ketan Parmar May 4, 2016 at 4:56 as my autocorrect type is no and if user start type it starts giving the suggestions all over again – Arun Kumar May 4, 2016 at 17:55

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.