1.添加属性touchView
@property (strong,nonatomic) UIView *touchView;
2.在代理方法中添加以下代码,如:
- (void)textViewDidBeginEditing:(UITextView *)textView{
self.touchView = [[UIView alloc] initWithFrame:self.view.frame];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget