0

一旦点击了调出附件控件,我试图简单地将 detailViewController 的标题设置为 pin 的标题。

这是我设置 MKAnnotation 的地方:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id 
<MKAnnotation>)annotation
{
MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] 
initWithAnnotation:annotation reuseIdentifier:@"loc"];

这是我想将详细视图控制器的标题设置为图钉标题的地方:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view     
calloutAccessoryControlTapped:(UIControl *)control
{

DetailViewController *controller = [[DetailViewController alloc] initWithNibName:nil
                                                                            bundle:nil];
[self.navigationController pushViewController:controller animated:YES]; // or use     
presentViewController if you're using modals

controller.title = pin.annotationView.subtitle;

}

最后一行是搞砸了。有任何想法吗?谢谢你们!!

4

2 回答 2

2

想通了 - 将控制器标题替换为:

controller.title = view.annotation.title;

谢谢大家!

于 2013-02-13T08:17:05.623 回答
1
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view     
calloutAccessoryControlTapped:(UIControl *)control
{
MKAnnotation * annotation = (MKAnnotation *)annotation;

DetailViewController *controller = [[DetailViewController alloc] initWithNibName:nil
                                                                            bundle:nil];
controller.title = annotation.subtitle;

[self.navigationController pushViewController:controller animated:YES]; // or use     
presentViewController if you're using modals

}

上面的代码对我来说很好,布兰登先生

于 2013-02-13T08:39:43.743 回答