MKMapView MKPointAnnotation tap event

前端 未结 3 553
旧巷少年郎
旧巷少年郎 2020-11-29 20:17

I have a list of annotations (MKPointAnnotation). I have a UIViewController which is for the whole view, MKMapView implementing Controller, which I thought is useful for det

3条回答
  •  孤街浪徒
    2020-11-29 21:09

    Add button in this method

    -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation 
    {
      pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
      pinView.canShowCallout = YES;
    }
    
    Then callout method
    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    {
          InfoView *infoView = [[InfoView alloc]initWithNibName:@"InfoView" bundle:nil];
            [self.navigationController pushViewController:infoView animated:YES];
    
    } 
    

提交回复
热议问题