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]??

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top