Question

I have tried the solutions at UITextView doesn't show InputAccessoryView on first click

I'm having a with a problem with a textView who has a inputAccessoryView

I want to call [textView resignFirstResponder] through its inputAccessoryView,so that i can close the keyboard

and there is only a UIButton on the inputAccessoryView,and the tapping the button will invoke an IBAction method call -(IBAction)closeKeyboard:(id)sender;

now the sender in the method is the button on the inputAccessoryView,

question is ,

how can i find out this textView whose inputAccessoryView has been tapped,

or just get a pointed which is pointed to this textView,so i can call

[textView resignFirstResponder]??

Was it helpful?

Solution

You need to find the current first responder. If you have outlets to all your text views, you can ask each one in turn

if ([textView1 isFirstResponder])
    [textView resignFirstResponder];

Though this may give you problems depending on your button (see here, but I haven't experienced this), if so use the editing property of the text view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top