1.UIScrollView在有点击手势的情况下,会导致UITableView的cell点击事件无法响应。
1 // 创建ScrollView 2 _scrollView = [[UIView alloc] initWithFrame:CGRectZero]; 3 _scrollView.backgroundColor = [UIColor whiteColor]; 4 [_baseScrollView addSubview:_scrollView]; 5 6 // 添加手势 7 UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleOfTapGRInScrollView:)]; 8 tapGR.delegate = self; 9 [_baseScrollView addGestureRecognizer:tapGR];
2.解决方案是实现点击手势的代理方法。
1 #pragma mark - 2 #pragma mark - UIGestureRecognizerDelegate 3 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 4 // 若为UITableViewCellContentView(即点击了tableViewCell),则不截获Touch事件 5 if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) { 6 return NO; 7 } 8 return YES; 9 }
3.参考文档。