我的图钉可以非常密集地填充,以便当一个图钉被选中时,标注弹出,但大多数情况下会被所有其他地图图钉遮挡-我可以将地图图钉放在前面它有一个代表选定的地图图钉(不是点击的标注,选定的图钉)。
对解决问题有什么建议吗?
发布于 2010-05-05 11:52:01
如果您使用的是自定义注释视图,则可以为选定的属性添加一个观察者,该观察者将在别针被选中时充当代理。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotation *annview = ...code to either dequeue or create new object...
[annview addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:@"selectedmapannotation"];
return annview;
}然后,您可以使用以下命令监视所选状态
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context;Mugunth Kumar链接的答案也会给你想要的结果,只是你在问题中提到了类似委托的功能。
编辑:
以下是observeValueForKeyPath:ofObject:change:context:方法内容的示例
NSString *action = (NSString*)context;
if([action isEqualToString:@"selectedmapannotation"]){
BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
MKAnnotationView *ann = (MKAnnotationView *)object;
if (annotationAppeared) {
// do something with the annotation when it is selected
}
else {
// do something with the annotation when it is de-selected
}
}发布于 2010-02-22 02:23:19
UICallout视图是MKAnnotationView的子视图。所以,我认为如果你把Map ping带到前面,UICAlloutView也会在那里。
https://stackoverflow.com/questions/1458052
复制相似问题