地图标注Annotation(小孩图标),当选中的时候会呼出一个弹框(callOut弹框).要在这个弹框中添加一个导航按钮,但是在点击的时候会出现无法响应到点击事件的情况.
这是由于响应者链条的关系.由于事件的传递会先判断点击的view,再判断touch点是否在自己身上来判断事件的传递.具体请点击这里查看关于hitTest:withEvent的介绍
重写annotationView的hitTest:withEvent:方法
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView *view = [super hitTest:point withEvent:event];
if (view == nil) {
CGPoint tempoint = [self.calloutView.guideBtn convertPoint:point fromView:self];
if (CGRectContainsPoint(self.calloutView.guideBtn.bounds, tempoint))
{
view = self.calloutView.guideBtn;
}
}
return view;
}