Search code examples
iosobjective-ciqkeyboardmanager

IQKeyBoardManager : Hide keyboard for a specific textfield


In my app I have a form where the user fills out his/her information, the form has some textfields and amongst those is one where the user can select their country. This textfiled is a dropdown which when active displays a dropdown (tableview) with the list of countries to select. I have created a demo project, to reproduce the issue and share it here. In this demo, I have add 3 textfields, when the user goes to the second textfiled, using the next button on the keyboard, a tableview is displayed. Now what I want to achieve is my keyboard should hide when the dropdown tableview is displayed. I have put in quite some time trying to figure this out but has no success. Here is the link to the demo project: https://github.com/tejaskutal/IQKeyboardManagerDemo

Any help is greatly appretiated.

P.S: For some weird reason, when you click next when the first textfiled is active, it jumps to the third one first and then goes to second textfield after next is clicked one more time. However, this has nothing to do with the original problem so I left it there.


Solution

  • No need to handle different delegate. In your viewDidload you can do something like,

     yourTextField.inputView = UIView.init(frame: CGRect.zero)
     yourTextField.inputAccessoryView = UIView.init(frame: CGRect.zero)
    

    so, for that textfield keyboard or toolbar will not be appeared.