use*_*785 0 iphone objective-c mapkit ios uistoryboardsegue
我正在尝试通过Google Places API将我当前加载到注释中的数据传递到我通过带有segue的故事板创建的详细视图控制器中.
我在单击每个注释上的详细信息披露时正确加载了详细视图控制器,但我正在尝试获取现在传递的数据.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
// Assuming I call the MapPoint class here and set it to the current annotation
// then I'm able to call each property from the MapPoint class but wouldn't
// I have to set this in the prepareForSegue but that would be out of scope?
MapPoint *annView = view.annotation;
// annView.name
// annView.address
[self performSegueWithIdentifier:@"showBarDetails" sender:view];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"showBarDetails"])
{
BarDetailViewController *bdvc = [self.storyboard instantiateViewControllerWithIdentifier:@"showBarDetails"];
//This parts confusing me, not sure how I obtain the data
// from the above mapView delegation method?
// annView.name = bdvc.name;
bdvc = segue.destinationViewController;
}
}
Run Code Online (Sandbox Code Playgroud)
在mapViewDelegate方法中
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
[self performSegueWithIdentifier:@"showBarDetails" sender:view];
}
Run Code Online (Sandbox Code Playgroud)
在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;
}
}
Run Code Online (Sandbox Code Playgroud)