7
votes

I have a storyboard, which includes navigation between views. Back and forth, and there is also the possibility to jump all the way to the home screen.

Basically, it works like this:

  • View 1 shows a simple menu.
  • View 2 shows input fields and automatically shows the keyboard.
  • View 3 shows a results table. In this view one can go one step back (to view 2) or back to the home screen (view 1).

The keyboard and everything works perfectly the first time, when the user moves from view 1 to view 2. However, when moving either back from view 3 to view 2, or from view 3 and starting all over again, the keyboard does not show.

In the code, I have becomeFirstResponder in the viewDidAppear method. Also, it will resignFirstResponder when loading view 3. Another interesting fact is that when calling the becomeFirstResponder for the second time, it does return NO (while it returns YES the first time). Also, when returning back to this view the textfields are not possible to select, even though they are userInteractionEnabled.

I am really stuck here, so any help is highly appreciated. I have seen several similar questions to this one, but not found a solution:

1
has anyone had any luck solving this ? I have looked all over and tried a bunch of things, but nothing works.. the keyboard will only show up 1 time per uitextfielduser353877

1 Answers

8
votes

I was able to track down the problem in my code. Answering this question myself since it might be helpful to others as well.

My issue was that I didn’t really get the order of events correct. I had a button that would move to the next textfield, and if everything was completed it would move to the next screen. This caused the becomeFirstResponder method to be called and not released (resignFirstResponder) when switching to a new screen.

I guess the main advice I can give (at least what finally worked for me), was to just go through all the becomeFirstResponder and make sure it is released before moving to next screen.