0

pinView 标注

我正在尝试为放置在 mapView 中的图钉自定义标注。我可以通过隐藏 pinView 的默认标注并在那里显示我的自定义标注来做到这一点。().. 一切正常...但唯一的问题是我无法为调用分配正确的信息..我已经显示了默认调用,其中信息与我的自定义调用不同。我已经附上了屏幕截图......

这是我的代码

-(void)mapViewImplementaion
{

    [mapview setMapType:MKMapTypeStandard];
    mapview.showsUserLocation=YES;


    for (int i =0;i<[allResultsArr count];i++)
    {
        List_Map_details *object=[allResultsArr objectAtIndex:i];

        CLLocationCoordinate2D coordinat = {[object.lati floatValue], [object.longi floatValue]};

        [mapview setRegion:MKCoordinateRegionMake(coordinat, 
                                                      MKCoordinateSpanMake(0.027f, 0.027f))];



DisplayMapPark *ann = [[DisplayMapPark alloc] init]; 

        ann.title =[NSString stringWithFormat:@"%@",object.forRetailerName];
        ann.subtitle=[NSString stringWithFormat:@"%@ %@ %@",object.forAddress,object.forZipCode,object.forCityName];
        ann.latitude=[object.lati floatValue];
        ann.longitude=[object.longi floatValue];
        ann.coordinate = coordinat; 
        [mapview addAnnotation:ann];
        [ann release];



}




CalloutMapAnnotationView *calloutMapAnnotationView;

int m=1;


-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {

    MKAnnotationView *pinView = nil; 



// here i wrote some code for my custom callout to generate(not shown)


if(annotation != mapview.userLocation) 
    {

        //int i=0;
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKAnnotationView *)[mapview dequeueReusableAnnotationViewWithIdentifier:defaultPinID];

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


        NSString *imagName = [NSString stringWithFormat:@"%d.png", m];
        UIImage *image = [UIImage imageNamed:imagName];
        [pinView setImage:image];

        pinView.canShowCallout = NO;
        // To show this in scrren Shot i set it to Yes;


        [pinView setAnnotation:annotation];

        pinView.tag=m;

        UIButton *rightButton=[UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinView.rightCalloutAccessoryView=rightButton;
        //pinView.rightCalloutAccessoryView.frame=CGRectMake(0, 0, 60, 60);

        m++;
    } 

    else 
    {
        [mapview.userLocation setTitle:@"Ik ben hier"];


    }

    pinView.annotation = annotation;
    [rightButton release];
    return pinView;

}

嗨,如果有人对此有所了解..请帮忙!!!!!!

4

1 回答 1

0

我解决了这个问题。这是我的错误。我只是没有正确地将标签分配给别针..当用户选择别针时,我正在阅读其他别针的信息......谢谢大家

于 2011-07-19T12:16:54.010 回答