Passing data from annotations to detail view iOS using storyboard

前端 未结 1 1808
天涯浪人
天涯浪人 2021-01-17 05:33

I\'m trying to pass the data that I have currently loaded into annotations via Google Places API into a detail view controller that I have created via storyboard with a segu

相关标签:
1条回答
  • 2021-01-17 05:39

    In mapView Delegate method

    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    {
        [self performSegueWithIdentifier:@"showBarDetails" sender:view];
    }
    

    In prepareForSegue:

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        if([[segue identifier] isEqualToString:@"showBarDetails"])
        {
            MapPoint *annotation = (MapPoint *)view.annotation;
    
            BarDetailViewController *bdvc = segue.destinationViewController;
            bdvc.name = annotation.name;
            bdvc.otherProperty = annotation.otherProperty;
    
        }
    }
    
    0 讨论(0)
提交回复
热议问题