MKMapView MKAnnotationView ISSUE?

前端 未结 2 1793
时光说笑
时光说笑 2021-01-26 02:00

I have a map view with pins that when the user selects a pin it goes to a detail screen for that pin. I also have a table view that when the user selects an item it goes to the

2条回答
  •  悲哀的现实
    2021-01-26 02:36

    -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    {    
        myAnnotation *annView = view.annotation; // myAnnotation is my custom class for annotations
        // now in annView you have the exact annotation whose accessorybutton is clicked now you can do whatever you want with it.
        NSLog(@"title = %@",annView.title);
    }
    

    Rather then setting the button tag you can use the title or subtitle of the annotation for futher comparision or whatever you want

    In your code you are using

    [newAnnotation addSubview:pinButton]; // i think this is wrong you should only add it to accessory view
    

提交回复
热议问题