Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField not getting keyboard input

I'm having troubles entering text into an UITextField under a SVProgressHUD (Basically an UIView with a full-screen transparent UIWindow and some UIView subviews showing text and a custom-drawn progress bar).

My problem is that the UITextField displays the blinking cursor and the keyboard shows, but when I tap a key, nothing is entered into the text field. I only see that the cursor's blinking interrupts just like normal. Interestingly enough, the back (delete) key works (it really deletes the last letter in the UITextView), but not any other key.

I'm using iOS 6.

Any help would be highly appreciated.

EDIT: The same UITextField works fine when there's no SVProgressHUD displayed. This makes me think it has something to do with the first responder, but I have already tried calling resignFirstResponder on every window and subview of the SVProgressHUD and it still does not work.

like image 335
FD_ Avatar asked Sep 29 '12 15:09

FD_


2 Answers

I finally found the problem: SVProgressHUD calls makeKeyAndVisible when it's initialized, because it wants to receive keyboard notifications for repositioning. I looked up what the "Key Window" actually is and found out:

...The key window responds to user input...

Now, as the UIWindow of the SVProgressHUD was the keyWindow, my other window, which contained the UITextField did not get the user input.

I finally call makeKeyWindow on the AppDelegate's window and everything is working fine.

I hope this helps anyone with similar problems.

like image 157
FD_ Avatar answered Oct 06 '22 01:10

FD_


Call resignFirstResponder() to dismiss the keyboard before showing SVProgressHUD.

like image 29
Bill Chan Avatar answered Oct 06 '22 00:10

Bill Chan