2010-11-12 108 views
0

我在我的应用程序中使用地图。如何在iPhone中创建自定义注释? PLZ给的链接到源...如何在iPhone中的地图中创建自定义注释?

+0

阅读[位置感知编程(http://developer.apple.com/library/ios/#documentation/UserExperience/ Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html%23 // apple_ref/doc/uid/TP40009497-CH6-SW1)以及示例应用程序KMLViewer,MapCallouts和WeatherMap。 – Anna 2010-11-12 13:38:27

回答

0

在viewForAnnotation功能

-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: 
(id <MKAnnotation>)annotation 
{ 
    MKPinAnnotationView *pinView=nil; 

    if(annotation!=mapView.userLocation) 
    { 
     static NSString *[email protected]"com.invasivecode.pin"; 
     pinView=(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 

     if(pinView==nil) 
      pinView=[[[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:defaultPinID]autorelease]; 

     pinView.pinColor=MKPinAnnotationColorRed;  
     pinView.canShowCallout=YES; 

     // to add button to annotation 
     UIButton *infobutton=[UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

     // add ibaction to the button added 
     [infobutton addTarget:self action:@selector(showdet:) forControlEvents:UIControlEventTouchUpInside]; 

     pinView.rightCalloutAccessoryView=infobutton; 
     pinView.animatesDrop=YES; 
     [defaultPinID release]; 
    } 
} 
相关问题