scrollview 上添加tableview , tableview 点击事件 无法响应,解决方法。

// 需要实现

//添加手势

- (void)viewDidLoad {

[super viewDidLoad];

UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:selfaction:@selector(touch)];

tapGes.delegate =self;

[self.view addGestureRecognizer:tapGes];

}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {

if([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {

returnNO;

}

returnYES;

}

#pragma mark -添加手势

- (void)touch {

[self.view endEditing:YES];

}

你可能感兴趣的:(scrollview 上添加tableview , tableview 点击事件 无法响应,解决方法。)