iOS隐藏默认键盘并打开自定义键盘

我有一个UITextview ,当用户点击UITextview我需要隐藏默认的键盘。 为此我已经做了,

  [myTextView setEditable: NO]; 

所以没有显示键盘,在这里,我用UIButton创build了一个自定义视图,当用户点击UITextView时,我需要显示这个UIView ,为此,

 textViewDidBeginEditing{ //Here i have added UIView as subview } 

但是这个方法是不行的,

 [myTextView setEditable: NO]; 

当用户点击UIView内的closuresbutton时,我需要closuresUIView

您应该使用resignFirstResponder而不是将UITextView设置为不可编辑。 这将隐藏系统键盘。

  [myTextView resignFirstResponder]; 

如果你想为键盘使用不同的视图,那么系统提供了一个,然后将inputView上的inputView设置为要用来代替系统键盘的自定义视图。

 myTextView.inputView = myCustomView; 

也许使用textFieldShouldBeginEditing而不是setEditable: NO作品?

 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { //Here i have added UIView as subview return NO; }