开发中经常会遇到子视图不响应父类手势的问题,解决方法:
- (void)cancelAction {
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hidden)];
tap.delegate = self;
[self addGestureRecognizer:tap];
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if ([touch.view isDescendantOfView:self.tableView]) {
return NO;
}
return YES;
}