FD_
FD_

Reputation: 12919

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.

Upvotes: 10

Views: 9743

Answers (4)

Bill Chan
Bill Chan

Reputation: 3455

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

Upvotes: 4

Narasimha Nallamsetty
Narasimha Nallamsetty

Reputation: 1263

For me this is worked.

I did changes in my textfield delegate method then it worked.

if ([textField isEqual:selectBankName])
{
   return No;
}
else if ([textField isEqual:enterAmountTextfield])
{
    return YES;
}

return NO;
}
  1. set delegate for textfield
  2. Make sure textfield userInteraction is Enabled.And

  3. Finally Please check your textfield delegate method.

Upvotes: 0

FD_
FD_

Reputation: 12919

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.

Upvotes: 35

Snips
Snips

Reputation: 6763

Have you implemented the method....

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text

...to filter out any unwanted characters? If so, perhaps it's being a little overzealous with the filtering?

Upvotes: 3

Related Questions