Pergunta

I am working on MKMap View which shows current location based on location coordinate and other custom annotations . It showing correctly on the Iphone 3gs but on iphone 4.0 or above it does not show the custom annotations every time (randomly it showing only green pin not the other ) . what can be the problem ? is there a problem in ios 4.0 and above ? if so how can we solve it .can anyone help me

Thanks

Code from viewForAnnotation method...

if ([annotation isMemberOfClass:[MKUserLocation class]]) 
{ 
    return nil; 
} 

if (annotation==self.normalAnnotation) 
{ 
    NSLog(@"green pin"); 
    MKPinAnnotationView *annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"NormalAnnotation"] autorelease]; 
    annotationView.canShowCallout = NO; 
    annotationView.pinColor = MKPinAnnotationColorGreen; 
    return annotationView; 
} 
else 
{ 
    NSLog(@"Custom pin"); 
    Marker *obj = [database getMarkerWithName:[annotation title]]; 
    MKAnnotationView *newAnnotation=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"]autorelease]; 
    newAnnotation.image = [UIImage imageNamed:obj.markerImage]; 
    newAnnotation.canShowCallout=YES; 
    UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; 
    [button setTag:obj.markerID]; 
    newAnnotation.rightCalloutAccessoryView=button; 
    //annotation.annotationObj = newAnnotation; 
    return newAnnotation; 
}
Foi útil?

Solução

I solved this , it happens because the pins are redrawing again and again since [location manager stopUpdatingLocation]is not working properly .so with bool variable I stop to call the class which initializes the Mapview again and again.

@aBitObvious : Thank u very much for ur support thanks...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top