0

コール アウト アクセサリ コントロールがタップされると、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;

}

最後の行はめちゃくちゃです。何か案は?皆さん、ありがとうございました!!

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

}

上記のコードは私にとってはうまくいきますMr.Brandon

于 2013-02-13T08:39:43.743 に答える