I am building a converter app. In the main screen I have a text field to input numbers and below the text field a picker view will allow users to select conversion parameters, (for example kg to g).
I can hide the keyboard when user click the background by using the following method
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self.enterInput resignFirstResponder];
but when I touch the picker view the keyboard is not hiding.
My question is how to dismiss the keyboard when a user touches the picker view.
Got a solution
1) First Create a hidden roundRect botton and change the type to custom (fit the size of the picker).
2) Create a touch up inside action
3) Create a keyboard appear notification
4) Create a keyboard disappear notification
5) Make the button visible when keyboard is appeared
6) Hide the button when the keyboard is disappeared
5) done
I dont think it is a perfect solution but it works for me 🙂