使用新版本(2.1.0)我遇到了问题。滚动地图时注释会消失。在演示项目中它工作正常。再次添加框架也无济于事。
- (void)viewDidLoad {
[super viewDidLoad];
placeDetail = [[PlaceDetailViewController alloc] init];
latitude = [placeDetail Latitude];
longitude = [placeDetail Longitude];
self.placeMapView = [[SKMapView alloc] init];
self.placeMapView.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));
self.placeMapView.delegate = self;
self.placeMapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.placeMapView.settings.poiDisplayingOption = SKPOIDisplayingOptionNone;
[self.view addSubview:self.placeMapView];
//add a circle overlay
for(int i=0;i<latitude.count;i++)
{
//set the map region
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake([latitude[i] floatValue], [longitude[i] floatValue]);
region.zoomLevel = 17;
self.placeMapView.visibleRegion = region;
SKAnnotation *mapAnnotation = [SKAnnotation annotation];
mapAnnotation.identifier = i;
mapAnnotation.minZoomLevel = 5;
mapAnnotation.annotationType = SKAnnotationTypeRed;
mapAnnotation.location = CLLocationCoordinate2DMake([latitude[i] floatValue], [longitude[i] floatValue]);
[self.placeMapView addAnnotation:mapAnnotation];
}
}
注释创建
-(void)mapView:(SKMapView *)mapView didSelectAnnotation:(SKAnnotation *)annotation {
self.placeMapView.calloutView.titleLabel.text= placeDetail.Name;
self.placeMapView.calloutView.titleLabel.font = [UIFont fontWithName:@"PTSans-Narrow" size:15];
self.placeMapView.calloutView.subtitleLabel.text = @"";
[self.placeMapView showCalloutForAnnotation:annotation withOffset:CGPointMake(0, 42) animated:YES];
[self.placeMapView.calloutView.rightButton addTarget:self action:@selector(backToDetailView) forControlEvents:UIControlEventTouchUpInside];
}
我会很感激你的帮助。
编辑:我想我发现了导致这种行为的问题。在我的应用程序中,我有两种地图。一张小地图和一张大地图。但在两种不同的看法。当我停用迷你地图时,它可以工作。所以我认为这与加载 SKMap 框架有关。目前小地图函数在view did load方法中被调用。所以你知道在这里做什么吗?