我正在尝试使自定义注释视图能够在没有成功的情况下响应触摸。
由于这个问题,我能够制作一个接近我想要为注释视图自定义标注气泡的注释视图?还看到了这个如何捕捉触摸而不关闭标注?但问题完全不同到目前为止我所做的第一件事是继承一个 MKAnnotationView 并覆盖 -setSelected:animated: 方法
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if(selected)
{
MyCallOut * callOut=[MyCallOut createMyCallOut];
callOut.tag=555;
[self.superview addSubview:callOut];
}
else
{
// [[self viewWithTag:555] removeFromSuperview];
//Remove my custom CallOut
}
}
问题是地图视图正在吃掉所有的触摸事件,我的自定义标注有两个按钮,但按下它们时不会触发任何操作。
在我的一项实验中,我尝试将标注视图添加到 MKAnnotationView 超级视图(mapView)中,当我滚动时,一切似乎都很好,但是如果我缩放标注会四处移动。