0

我正在使用地图视图。当我放大地图时,它显示确实收到内存警告并在 iOS 6 设备中使应用程序崩溃。但它在以下版本中工作正常。当我放大时它占用了更多内存但它没有被释放如何释放它我已经在释放方法中释放了所有对象但它仍然显示同样确实收到内存警告并使我的代码所在的应用程序崩溃

       mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
    mapView.showsUserLocation = YES;
    [mapView setDelegate:self];
    [self addSubview:mapView];
    routeView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, mapView.frame.size.width, mapView.frame.size.height)];
    routeView.userInteractionEnabled = NO;
    [mapView addSubview:routeView];

      - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
    {
       if([annotation isKindOfClass:[TurnAnnotation class]])
{
    MKAnnotationView *turnAnnotationView=[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:nil] ;
    turnAnnotationView.image=[UIImage imageNamed:@"TurnAnnotation1.png"];

    turnAnnotationView.canShowCallout=NO;
    return turnAnnotationView;
}
else if([annotation isKindOfClass:[PlaceMark class]])
{
    MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];

    if (isdefault==YES) {
        if(!appDel.appBOOL){
            newAnnotation.pinColor = MKPinAnnotationColorGreen;
            appDel.appBOOL = YES;
        }else {
            newAnnotation.pinColor = MKPinAnnotationColorRed;
            appDel.appBOOL = NO;
        }
    }else{


    if(!appDel.appBOOL){
        newAnnotation.pinColor = MKPinAnnotationColorRed;
        appDel.appBOOL = YES;
    }else {
        newAnnotation.pinColor = MKPinAnnotationColorGreen;
        appDel.appBOOL = NO;
    }
    }

    newAnnotation.canShowCallout = YES;

    return newAnnotation;
}
return nil;

}

4

1 回答 1

0

会不会是你的 iOS6 测试用例是 Retina 版本?视网膜图像占用 4 倍的内存。不应忽略内存不足警告。

于 2013-06-13T09:13:58.183 回答