0

我已经尝试过UITextView 的解决方案在第一次单击时不显示 InputAccessoryView

我对具有inputAccessoryView的textView有疑问

我想通过它的inputAccessoryView调用[textView resignFirstResponder],这样我就可以关闭键盘

并且inputAccessoryView上只有一个UIButton,点击该按钮将调用 IBAction 方法调用-(IBAction)closeKeyboard:(id)sender;

现在方法中的发送者是inputAccessoryView上的按钮,

问题是,

我怎样才能找出这个textView 的 inputAccessoryView 已被点击,

或者只是得到一个指向这个textView的指针,所以我可以打电话

[textView resignFirstResponder]??

4

1 回答 1

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.

于 2011-10-04T08:42:12.330 回答