繁体   English   中英

iOS:缩小地图时应用崩溃

[英]iOS : App crashes when zooming out a map

在这种情况下,缩小地图会导致我的应用崩溃。

由于要添加大量注释,因此出现了问题。 请在下面查看我的代码:

- (void) plotUsersInMap
{
for (id<MKAnnotation> annotation in self.mapView.annotations) {
    [self.mapView removeAnnotation:annotation];
}

NSUInteger count = //get total count
NSLog(@"count * %d", count);
for (int i = 0; i < count; i++)
{
    NSNumber *latitude = //get latitude from json
    NSNumber *longitude = //get longitude from json

    CLLocationCoordinate2D coordinate;
    coordinate.latitude = latitude.doubleValue;
    coordinate.longitude = longitude.doubleValue;

    @autoreleasepool {

        MyLocation *annotation = [[MyLocation alloc] initWithName:@"test" coordinate:coordinate QuestionId:nil];
       //annotations are added
        [self.mapView addAnnotation:annotation];
    }
}
}

在这里,我试图添加400多个引脚,我认为这是导致崩溃的原因(可能是内存泄漏!)。 我想知道在缩小时是否可以一一添加引脚吗?

初始地图,没有任何问题: 初期

当我缩小时:

它崩溃了!

尝试聚类 基本上,您将注释分组在一起。

我链接到的文章的代码仓库: https : //github.com/applidium/ADClusterMapView

暂无
暂无

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

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