1

MKMapView を使用すると、Instruments によるとリークが発生します。私のコードは次のとおりです。

mapView = [[MKMapView alloc] initWithFrame:self.bounds];
mapView.mapType = MKMapTypeStandard;
mapView.delegate = self;
[self addSubview:mapView];

マップビューの割り当てを解除します。次のコードは MKAnnotationView 用です。

-(MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    WeatherItem *weatherItem = (WeatherItem *)annotation;
    static NSString *AnnotationViewID = @"annotationViewID";

    WeatherAnnotationView *annotationView = (WeatherAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
    if (annotationView == nil)
    {
        annotationView = [[[WeatherAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
    }

    SWPeripheryIndicator *perpheryIndicator = [[SWPeripheryCache sharedPeripheryCache] onePeripheryCityInfo:[weatherItem cityCode]];
    if (perpheryIndicator==nil && MKMapRectContainsPoint(map.visibleMapRect, MKMapPointForCoordinate(annotation.coordinate))) 
    {
        [[SWeatherEngine sharedSWeatherEngine] getPeriphyWeather:weatherItem.cityCode];
        [onDownLoadView setObject:annotationView forKey:weatherItem.cityCode];
    }


    annotationView.cityCode = weatherItem.cityCode;
    annotationView.annotation = annotation;
    [annotationView updatePeripheryInfo:weatherItem.cityName shouldDisplayData:perpheryIndicator];

    return annotationView;
}
4

0 に答える 0