1

嗨,我正在处理我的第一个应用程序。请找到下面的代码并帮助我解决这个问题。

当我加载地图时,我正在加载地图中的所有注释,但是当我将地图拖到更多注释附近时,如果大约有 100 个注释没问题,则根据注释计数冻结一段时间,但有时我会得到更多2000 到 4000 个注释,当时应用程序冻结了更多时间,因为我观察到当我将地图拖到这些注释附近时,只有那些标题正在加载(阅读)。我该如何解决这些冲突。有什么办法可以通过在后台加载标题或任何其他方式应用程序不应该冻结来解决这个问题。

如果您有任何参考,请更新我。

- (MKAnnotationView *)mapView:(MKMapView *)mv viewForAnnotation:(id <MKAnnotation>)annotation
 {
static NSString *reuseId = @"reuseid";
MKAnnotationView *av = [_map_view dequeueReusableAnnotationViewWithIdentifier:reuseId];
if (av == nil)
{
    av = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseId] ;
}
else
{
    av.annotation = annotation;
}

NSLog(@"Title %@",annotation.title);

NSString *title = StringOrEmpty(annotation.title);

if ([title isEqualToString:@"Current Location"] )
{
    av.image = [UIImage imageNamed:@"user_icon21.png"];
    av.centerOffset = CGPointMake(0.0f, -17.5f);
}
else if ([title isEqualToString:@""])
{
    av.image = nil;
}
else
{
    av.image = [UIImage imageNamed:@"Rmap1.png"];
    av.centerOffset = CGPointMake(0.0f, -15.0f);
}
av.canShowCallout = YES;

return av;

在此先感谢,感谢您的帮助。

4

0 回答 0