代碼如下:
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resignTextView)];
[self.tableview addGestureRecognizer:gestureRecognizer];
-(void)resignTextView
{
[textView resignFirstResponder];
}
我用UITapGetureRecognizer
添加tableview
,但是不知道為什麼不成功?
添上這句:
gestureRecognizer.numberOfTapsRequired = numberOfTapsRequired;
在numberOfTapsRequired
是int類型處試試,默認是1,你可以從2開始。