This should be simple, but it's becoming a headache. I have a view with a UITextField where the user types some text and clicks search. This pops up another view controller, and I resign first responder on the text field before the first view disappears. When the second view gets dismissed, the first view automatically makes the text field become first responder again and I can't find a way to suppress this. Does anyone have any idea how I can keep the keyboard from popping up when I dismiss the second view?
I tried to resignFirstResponder in viewWillAppear, no effect. I tried the same in viewDidAppear, but the keyboard pops up and then immediately dismisses which is awkward looking.
I appreciate any help.
I found a fix, but its not a very good one.
Found that canBecomeResponder message was being passed to the textfield right after viewWillAppear
and before viewDidAppear
.
So I set a BOOL value in viewDidAppear
to YES, and used that value in textField:shouldBeginEditing
method. Basically if the viewDidAppear
was not called yet, textField:shouldBeginEditing
was returning NO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With