![](/img/trans.png)
[英]SKMaps, way to clear in-memory cache for map data when receiving memory warning from iOS?
[英]SKMaps iOS: Pin disappears when panning the Map
使用新版本(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];
}
}
Annoation創作
-(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];
}
我很感激你的幫助。
編輯:我想我發現了導致這種行為的問題。 在我的應用程序中,我有兩種地圖。 一張迷你地圖和一張大地圖。 但在兩個不同的觀點。 當我停用Mini Map時,它可以工作。 所以我認為它與加載SKMap框架有關。 目前迷你地圖功能在視圖中調用了load方法。 所以你知道該怎么做嗎?
這是SDK的2.1和2.2版本中的一個錯誤 - 它將在2.3(2014年11月)中修復。
對於2.1 / 2.2,有一種解決方法:對小地圖和大地圖上的注釋使用不同的id。 例如,你在小地圖上有N個注釋,其中有ids 0..N-1,那么大地圖將有來自N向前的ids的注釋。 因此,對於大地圖上的M注釋,您可以使用N..M-1中的ID進行注釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.