像svpply做的这样,UITableView盖在MKMapView上面,但是UITableView顶部产生事件时,事件能够分发到MKMapView上去
我试了重写tableView的
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
里面直接
[self.nextResponder touchesBegan:touches withEvent:event];
或者
[mapView touchesBegan:touches withEvent:event];
都不行,事件还是被table吃了
怎么办?
解决办法:重写了tableview的hittest成功了,感谢@navy
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *view = [super hitTest:point withEvent:event]; if (view == self.tableHeaderView) { return nil; } return view; }
或许你需要的是这个方法,确切说我是没大明白你的意思。
tableview上怎么还用touch事件?是cell上add的view要传递到下层?
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event; // recursively calls -pointInside:withEvent:. point is in the receiver's coordinate system
需要传递的view都实现这个方法,这样touch的事件层级传递就都能收到。