selectAnnotation删除后,然后重新添加注解
问题描述:
嘿所有,我有一个关于iPhone的mapKit密集的问题。selectAnnotation删除后,然后重新添加注解
我正在使用MapKit框架,我试图做的是基本上单击一个引脚,重新加载它,然后再次显示它的callOut。
这是我想要去工作的代码..
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
NSLog(@"count of selected Annotations: %d",[mapView selectedAnnotations].count);
MKAnnotation* pin = view.annotation;
[mapView deselectAnnotation:pin animated:FALSE];
[mapView removeAnnotation:pin];
[mapView addAnnotation:pin];
[self.mapView selectAnnotation:pin animated:TRUE];
一些意见:如果我评论的removeAnnotations和addAnnotation行了,我进入了无限循环,因为当我selectAnnotation:针,回调(这是这种方法)被称为...否则,它不是,但那么是什么?为什么不是
[self.mapView selectAnnotation:pin animated:TRUE];
被调用?
我已经读得太多了,并且打破了我的头太多的时间试图弄清楚,解释和修复我的代码会比链接更有帮助。
在此先感谢。 〜Fydo
答
所以我已经回答了我的问题...看来,最简单的方法在点击它改变注释,如下:
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
MKAnnotation* pin = view.annotation;
UIImageView * blackPin = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PinUnchecked.png"]];
[[mapView viewForAnnotation:pin] addSubview:blackPin];
此委托方法将被调用,那么注释视图气泡将被显示,并且注解视图将改变它的图像......这就是我所需要做的......