2013-02-13 64 views
0

我想簡單地設置一個detailViewController的標題爲引腳的標題,一旦出來的附件控件被調出。從calloutAccessoryControlTapped設置ViewController標題

這裏就是我設置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; 

} 

最後一行是搞砸了。有任何想法嗎?謝謝你們!!

回答

2

想通了 - 代之以控制器標題:

controller.title = view.annotation.title; 

謝謝大家!

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