我试图在点击呼出附件控件后简单地将detailViewController的标题设置为引脚的标题。
这是我设置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;
}
最后一行是搞砸的。有任何想法吗?谢谢大家!!
答案 0 :(得分:2)
想出来 - 用:
替换控制器标题controller.title = view.annotation.title;
全部谢谢!
答案 1 :(得分: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
}
以上代码适用于我Mr.Brandon