StartFirstResponder doesn't show keyboard a second time (ios 6 + storyboard)

I have a storyboard that includes navigation between views. Back and forth, and there is also the opportunity to completely go to the main screen.

Basically, it works as follows:

  • View 1 shows a simple menu.
  • View 2 shows the input fields and automatically shows the keyboard.
  • Presentation 3 shows a table of results. In this view, you can take one step back (to view 2) or return to the main screen (view 1).

The keyboard and everything works fine the first time the user switches from view 1 to view mode 2. However, when you move backward from view 3 to view mode 2, or from window 3, the keyboard does not show again.

In code, I became FirstResponder in the viewDidAppear method. In addition, it will resignFirstResponder when loading view 3. Another interesting fact is that when you call startFirstResponder a second time, it returns NO (as long as it returns YES for the first time). In addition, when returning to this view, text fields cannot be selected, even if they are userInteractionEnabled.

I am really stuck here, so any help is much appreciated. I saw several similar questions to this, but could not find a solution:

+6
source share
1 answer

I was able to identify a problem in my code. The answer to this question itself, as it may be useful for others.

My problem was that I really didn't get the order of events. I had a button that would move to the next text box, and if everything is completed, it will move to the next screen. This caused the beginFirstResponder method to be called and not released (resignFirstResponder) when switching to a new screen.

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

+7
source

Source: https://habr.com/ru/post/927131/


All Articles