How to load multiple annotation titles without freezing the application in iOS

261 views Asked by At

Hi i am working in my first application. plz find the below code and help me out in this.

When i am loading the map i am loading all the annotations in map but when i drag the map near to more annotations app is Freezing for some time based on annotation count if there is around 100 annotations no problem but some times i am getting more then 2000 to 4000 annotations, at that time app is freezing for more time, Because i observed when i drag map near to those annotations then only those titles are loading(reading). How can i resolve these conflict. Is there any way i can fix that issue by loading the titles in back ground or any other way app should not freeze.

If you are having any reference update me .

- (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;

Thanks in advance,helping hands appreciated.

0

There are 0 answers