让超出父控件的位置也可正常响应事件
作者:
那就这样吧_ | 来源:发表于
2017-07-25 16:56 被阅读0次当tableView的显示范围超出了父view的边界,这时点击超出部分,事件会穿透过去,忽略掉该tableView的响应事件,这时给view添加如下方法,超出父控件的位置就可以正常触发响应了。
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *result = [super hitTest:point withEvent:event];
CGPoint viewPoint = [self.tableView convertPoint:point fromView:superView];
if ([self.tableView pointInside:viewPoint withEvent:event]) {
return self.tableView;
}
return result;
}
本文标题:让超出父控件的位置也可正常响应事件
本文链接:https://www.haomeiwen.com/subject/mjxgkxtx.html
网友评论