iOS uitableView响应事件被拦截
来源:程序员人生 发布时间:2014-11-17 08:31:57 阅读次数:2864次
//添加手势,点击屏幕其他区域关闭键盘操作
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(SEL)];
gesture.numberOfTapsRequired = 1;
gesture.delegate = self;
[self.view addGestureRecognizer:gesture];
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
// 若为UITableViewCellContentView(即点击了tableViewCell),则不截获Touch事件
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
return NO;
}
return YES;
}
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠