8
votes

One of my ipad app screen having multiple textfield. On that few textfields are generating popup for user input action/decision/prepopulate info etc. It is working fine when default ipad keyaboard is using. but when we tried with external keyboard with tab key, I am getting multiple textfieldshouldbeginediting events for all presence textfields. I have added all logic into textfielddidbeginediting methods, but I am not able to hide the keyboard which are popup due to textfieldshouldbeginediting through other key events which are generate due to tab key. how can we stop tab key events from external device? or I dont want to get multiple textfieldshouldbeginediting when tab key is pressed.

I can reproduce this issue through simulator & use macbook keyboard tab key for multiple uitextfields.

TextField becomeFirstResponder Issue for tab key(Keyboard) action

2
Thx for sharing that "textfieldshouldbeginediting: is called for all text fields". This is exactly what happened to our app on the iOS 9.1 iPad simulator when "tab" key is pressed.Golden Thumb

2 Answers

1
votes

I had a similar issue and ended up having to put all logic in textfielddidbeginediting methods.

To dismiss the keyboard, you can just use your own method doing something like:

[self.view endEditing:YES];
0
votes

Spent about 2 hours looking for this solution. If you need to do this in Swift and want to popup a field after pressing tab onto a field here is the code:

func textFieldDidBeginEditing(_ textField: UITextField) {
    if textField == yourIBOutletReference { //Could also check via Tags.
        self.view.endEditing(true)
        yourPopupFunction()
    }
}