0

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

Community
  • 1
  • 1
Wang Liang
  • 941
  • 2
  • 15
  • 34

1 Answers1

0

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.

Community
  • 1
  • 1
jrturton
  • 118,105
  • 32
  • 252
  • 268
  • thanks a lot! Your solution seems better than mine. Since this viewController has no IBOutlets and views are created all by code, so it seems to be a little more tough, – Wang Liang Oct 04 '11 at 08:58