本文介绍了iOS的Mapkit - 注解消失在地图上滚动/缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在初始加载,注释显示就好了。但是,如果我滚动地图,它们都将消失,code仅要求用户位置,而不是在viewForAnnotation委托方法的其他注释。
剧情销
- (无效)viewDidLoad中{
......从网络下载坐标和数据在这里...
[self.mapView addAnnotation:密码];
}
委托方法
- (MKAnnotationView *)的MapView:(*的MKMapView)的MapView viewForAnnotation:(ID< MKAnnotation>)注释
{
//播放器的引脚
如果([注解类] == MKUserLocation.class){
回零;
} //集群针
如果([注解isKindOfClass:[REVClusterPin类]){
REVClusterPin *销=(REVClusterPin *)注释;
如果([销nodeCount]&0){
pin.title = @___; MKAnnotationView * annotationView =(REVClusterAnnotationView *)[图形页面dequeueReusableAnnotationViewWithIdentifier:@集群]; 如果(!annotationView){
annotationView =(REVClusterAnnotationView *)
[REVClusterAnnotationView页头] initWithAnnotation:注释reuseIdentifier:@集群];
} annotationView.image = [UIImage的imageNamed:@cluster.png]; [(REVClusterAnnotationView *)annotationView setClusterText:
[的NSString stringWithFormat:@%i的,[针nodeCount]]]; annotationView.canShowCallout = NO;
返回annotationView;
}
}
//播放器引脚
如果([注解isKindOfClass:[ZEPointAnnotation类]){
ZEPointAnnotation *销=(ZEPointAnnotation *)注释;
MKAnnotationView * annotationView = [图形页面dequeueReusableAnnotationViewWithIdentifier:@针];
如果(!annotationView){
annotationView = [[MKAnnotationView页头] initWithAnnotation:注释reuseIdentifier:@针];
}
annotationView.canShowCallout = YES;
annotationView.draggable = NO; ...创建PIN数据在这里... 返回annotationView;
}
回零;
}
解决方案
删除动画。这将解决您的问题。
On initial load, the annotations show just fine. But if I scroll the map, they all disappear and the code is only called for the user location, not the other annotations in the viewForAnnotation delegate method.
Plot Pins
-(void)viewDidLoad{
...Download Coordinates and Data from Web here...
[self.mapView addAnnotation:pin];
}
Delegate Method
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
//Player's Pin
if([annotation class] == MKUserLocation.class) {
return nil;
}
//Cluster Pin
if([annotation isKindOfClass:[REVClusterPin class]]){
REVClusterPin *pin = (REVClusterPin *)annotation;
if( [pin nodeCount] > 0 ){
pin.title = @"___";
MKAnnotationView *annotationView = (REVClusterAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"cluster"];
if( !annotationView ){
annotationView = (REVClusterAnnotationView*)
[[REVClusterAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"cluster"];
}
annotationView.image = [UIImage imageNamed:@"cluster.png"];
[(REVClusterAnnotationView*)annotationView setClusterText:
[NSString stringWithFormat:@"%i",[pin nodeCount]]];
annotationView.canShowCallout = NO;
return annotationView;
}
}
//Player Pin
if([annotation isKindOfClass:[ZEPointAnnotation class]]){
ZEPointAnnotation *pin = (ZEPointAnnotation *)annotation;
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"];
if(!annotationView){
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"];
}
annotationView.canShowCallout = YES;
annotationView.draggable = NO;
...Create Pin Data Here...
return annotationView;
}
return nil;
}
解决方案
remove animations. that will solve your problem
这篇关于iOS的Mapkit - 注解消失在地图上滚动/缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!