我正在使用parse来检索数据,我如何将具有地图视图的viwecontroller中的对象ID传递给另一个视图控制器,
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
[self performSegueWithIdentifier:@"MapToDeal" sender:view.annotation];
NSLog(@"%@",view.annotation.title);
}
答案 0 :(得分:0)
在.m文件中编写此方法
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString: @"MapToDeal"])
{
DetailViewController *detailViewController = [segue destinationViewController];
detailViewController.annotview = sender; //here annoteview is object in DetailViewcontroller
}
}
或 你也可以这样做
In mapView Delegate method
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
[self performSegueWithIdentifier:@"MapToDeal" sender:view];
}
In prepareForSegue:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"MapToDeal"])
{
MapPoint *annotation = (MapPoint *)view.annotation;
DetailViewController *dvc = segue.destinationViewController;
dvc.name = annotation.name;
dvc.anyproperty = annotation.anyproperty;
}
}