寫入該方法中.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;
}
}
你可以使用委託和協議。 – lighter
你能幫助一個示例代碼 – mugunthan
你可以參考這個網站http://ios-blog.co.uk/tutorials/how-to-create-an-objective-c-delegate/ – lighter