在高德地图 弹框里添加点击事件,会出现无法点击的情况
之所以这样,这是由于响应者链条的关系.由于事件的传递会先判断点击的view,再判断touch点是否在自己身上来判断事件的传递
解决:重写annotationView的hitTest:withEvent:方法
这里添加了两个点击事件
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *view = [super hitTest:point withEvent:event];
if (view == nil) {
CGPoint tempoint = [self.calloutView.btnV convertPoint:point fromView:self];
if (CGRectContainsPoint(self.calloutView.btnV.bounds, tempoint))
{
view = self.calloutView.btnV;
}
CGPoint tempoint2 = [self.calloutView.title convertPoint:point fromView:self];
if (CGRectContainsPoint(self.calloutView.title.bounds, tempoint2))
{
view = self.calloutView.title;
}
}
return view;
}
我的业余技术微信公众号:YKJGZH,欢迎大家进入