0

我想要在點擊xcode中mapview註釋上的右鍵之後顯示詳細視圖,但是我無法獲取要顯示的視圖, 我的代碼:試圖推動一個詳細視圖,當在xcode中註釋mapview的註釋時點擊右鍵

- (void)showDetails:(id)sender 
{ 
    [self.navigationController setToolbarHidden:YES animated:NO]; 

[self.navigationController pushViewController:self.detailViewController animated:YES]; 

} 



- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier"; 

MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc] 
             initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier] autorelease]; 
customPinView.pinColor = MKPinAnnotationColorPurple; 
customPinView.animatesDrop = YES; 
customPinView.canShowCallout = YES; 

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
NSLog(@"%@",rightButton); 
[rightButton addTarget:self 
       action:@selector(showDetails:) 
     forControlEvents:UIControlEventTouchUpInside]; 
customPinView.rightCalloutAccessoryView = rightButton; 
return customPinView;//[kml viewForAnnotation:annotation]; 
} 

的showDetails方法被調用,但不能推detailViewController頂端,

[self.navigationController pushViewController:self.detailViewController animated:YES]; 

這段代碼應該推詳細視圖頂部和顯示的DetailView但它確實不請,

任何幫助,將不勝感激,我想做的事情是,當有人上的MapView註釋的右鍵水龍頭,我想展示的細節圖,請多關照..

+0

您可能會覺得有用在這個問題的信息http://stackoverflow.com/questions/8285153/regarding-apples-kmlviewer-placemarkdescription-and-annotation-subtitle – Hari 2012-03-21 22:56:35

回答

1

有無需目標/行動,有一個委託方法時標註附件視圖被竊聽被調用:mapView:annotationView:calloutAccessoryControlTapped:

+0

好吧,我有一個detailViewController如何顯示右視圖時,該視圖點擊。 – jarus 2012-03-08 08:35:00

0

謝謝您的幫助,我能夠改變我的showDetails方法打開detailViewController

- (void)showDetails:(id)sender 
    { 
     detailViewController *dvController = [[detailViewController alloc] initWithNibName:nil bundle:nil]; 
     [self presentModalViewController:dvController animated:YES]; 
     [dvController release]; 
     dvController = nil; 
    }