0

pinView Callout

I am trying for a custom callout for a pin dropped in a mapView .. I am able to do this by hiding the default callout of pinView and showing my custom call out there. ().. everything is working fine ... But only prob is i am not able to assign the correct information for the call out ..I had shown the Default call out in which info is different than my custom call out. I ve attached the scrren shot .....

Here is my code

-(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;

}

Hi if any one is awre of this .. please help !!!!!

Naren
  • 115
  • 2
  • 14
  • Have we got all relevant code here? Seems we may be missing your custom callout code? – Lee Armstrong Jul 18 '11 at 06:34
  • Hi Lee. Yeah the custom pop out code i have removed .... its just the matter of pin lati and longi assingning. – Naren Jul 18 '11 at 13:17
  • Well for us to help then we do need to see that code as I suspect that is where the issue is! The other code you have posted looks ok – Lee Armstrong Jul 18 '11 at 14:21
  • http://www.jakeri.net/2009/12/custom-callout-bubble-in-mkmapview-final-solution/ i think this blog have step by step solution if it is not useful for your concept please ignore – Deepesh Jul 18 '11 at 06:40
  • @Naren It would be good if you remove the question as it wastes time of lots of user who first of all checks out the question and then looks at your answer that this was not an issue to be solved. – Suresh Varma Nov 21 '11 at 11:55
  • @Naren, I am having problem with adding UIbuttons to custom accessory view. How do you did that? In my case button action is not getting called – chatur Dec 15 '11 at 11:00
  • @chatur ... Well for a button use the contorlevent as like this .... [button addTarget:self action:@selector(methodName)forControlEvents:UIControlEventAllTouchEvents]; TouchUpInside is not fired – Naren Dec 19 '11 at 11:52
  • as S P Varma already mentioned, it would be good this question would be removed, since it is misleading and really helpful to others – Flori Sep 12 '12 at 20:58

1 Answers1

0

I solved this issue. It was the mistake by me. I was just not assigning the tags to the pins properly .. and when the user selects the pin i was reading some other pin's information.... Thanks all

Naren
  • 115
  • 2
  • 14