2010-12-06 21 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

相關問題