2010-12-06 2 views

ответ

1
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ 
    MKPinAnnotationView *pinView = nil; 
    static NSString *defaultPinID = @"CameraAnnotation"; 
    pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
    if (pinView == nil) 
     pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease]; 
     UIImageView *pinImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 24, 32)]; 
     UIImage *pinImage = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"pinImage" ofType:@"png"]]; 
     pinImageView.image = pinImage; 
     [pinImage release];   

     [pinView addSubview:pinImageView]; 
     [pinImageView release]; 

     pinView.canShowCallout = YES; 
     pinView.animatesDrop = YES; 

     UIButton* photoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     photoButton.tag = ((PinAnnotationView*)annotation).tag; 
     pinView.leftCalloutAccessoryView = photoButton; 
     return pinView; 
    } 
} 
+0

жаль, что я не знаю, это моя ошибка или нет, но моя программа падает на photoButton.tag = ((PinAnnotationView *) аннотации) .tag; – Saawan 2010-12-06 05:27:07

Смежные вопросы