Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:缩小地图时应用程序崩溃_Ios_Maps_Mkannotation - Fatal编程技术网

iOS:缩小地图时应用程序崩溃

iOS:缩小地图时应用程序崩溃,ios,maps,mkannotation,Ios,Maps,Mkannotation,我的应用程序在缩小地图时崩溃 问题的出现是因为我添加了大量注释。请查看下面我的代码: - (void) plotUsersInMap { for (id<MKAnnotation> annotation in self.mapView.annotations) { [self.mapView removeAnnotation:annotation]; } NSUInteger count = //get total count NSLog(@"count * %d", co

我的应用程序在缩小地图时崩溃

问题的出现是因为我添加了大量注释。请查看下面我的代码:

- (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];
    }
}
}
-(void)plotUsersInMap
{
for(self.mapView.annotations中的id注释){
[self.mapView removeAnnotation:annotation];
}
NSUTEGER count=//获取总计数
NSLog(@“计数*%d”,计数);
for(int i=0;i
我试图添加超过400个引脚,我认为这是崩溃的原因[可能是内存泄漏!]。我想知道是否有任何方法可以在缩小时一个接一个地添加管脚

初始阶段的地图,没有任何问题:

当我缩小时:

试试看。基本上是将注释分组在一起


我链接到的文章中的代码repo:

还不能处理这个问题。但如果地图缩小,我通常看到的是,当插针彼此太近时,它们会被移除并替换为1个插针。试试看,你的针数应该过多。因此,在您的上一张图片中,它将有9个引脚。您可以向您展示委托方法-(MKAnnotationView*)mapView:(MKMapView*)mapView视图进行注释:(id)注释吗?@ikeKamstra感谢您的建议。使用集群解决了这个问题。