0
votes

I am using a UIView combined out of several views that one of them is UITextView.

When UITextView becomes first responder I set the UIView to be its InputAccessoryView. The keyboard goes up fine with its accessory view.

The problem is that it look like the UITextView is the first responder because text can be typed inside immediately (without clicking the cursor in) but when trying to dismiss the keyboard it won't go down and even if navigating back the keyboard will remain up.

Only when I click again on the UITextView, I can dismiss the keyboard and when I navigate back the keyboard goes down.

Does anyone has any idea , what is going on?

I think there might be some recursion with the UIResponder, since the UITextView is inside its own inputAccessoryView, any ideas how can I solve this?

2

2 Answers

0
votes

I also had this problem. Solved it with:

[self.view endEditing:YES];
0
votes

I find the cause is that when being set as inputAccessoryView, the UITextView is not the FirstResponder now. Anyway if you touch the UITextView again, it becomes the first responder, and then everything goes OK.

So my (ugly) solution on iphone is:

  1. Observe UIKeyboardDidShowNotification:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];

  2. After receiving UIKeyboardDidShowNotification, send becomeFirstResponder to the UITextView again(in keyboardDidShow:).

I have tested putting the code into textViewShouldBeginEditing: but at that time, the inputAccessoryView is not shown on screen, so it still can not become the first responder?

@takeshi-kaga I have tried your way, but it does not work.Could you share up more details?