简体   繁体   English

ios7 sdk中的MKMapView内存问题

[英]MKMapView memory issues in ios7 sdk

i have MKMapView in a view controller and when i starts zooming on it consume a lot of memory and when i leave the view who contains the MKMapView the memory is not released (I am using ARC in my App) 我在视图控制器中有MKMapView,当我开始放大时,它消耗了大量内存,当我离开包含MKMapView的视图时,内存未被释放(我在我的应用程序中使用ARC)

Edit : 编辑

i read in some stack overflow answers that i have to put the MKMapView in AppDelegate : 我读了一些堆栈溢出答案,我必须把MKMapView放在AppDelegate中:

-(MKMapView*) mapView
{
    if(_mapView == nil) {
        _mapView = [[MKMapView alloc] init];
    }
    return _mapView;
}

and in viewWillDisappear of viewController that contains the MKMapView put 并且在包含MKMapView put的viewController的viewWillDisappear中

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    XAppDelegate.mapView.delegate = nil;
    [XAppDelegate.mapView removeFromSuperview];

}

but it did not resolve my problem. 但它没有解决我的问题。

A common flaw I've seen is that the MKOverlay is holding a strong reference to the MKOverlayView / MKOverlayRender and the MKMapView . 我见过的一个常见缺陷是MKOverlay对MKOverlayView / MKOverlayRenderMKMapView有强烈的引用。 This causes a retain cycle because the MKMapView holds a strong reference to the MKOverlay instances as well. 这会导致保留周期,因为MKMapView拥有对MKOverlay实例的强引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM