2011-07-02 26 views
0

我有一張基於用戶位置顯示各種引腳的地圖。我可以查看引腳和標註沒有問題。當我按下詳細披露按鈕時,我的MapDetailInfo不會加載。這是一些代碼。註解詳細視圖無法在Mapkit中加載

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation 
{ 
// Specify which MKPinAnnotationView to use for each annotation. 

MKPinAnnotationView *businessListingPin = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier: @"BLPin" ]; 

if (businessListingPin == nil) 
{ 
    businessListingPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"BLPin"]; 
} 
else 
{ 
    businessListingPin.annotation = annotation; 
} 

// If the annotation is the user's location, don't show the callout and change the pin color 
if(annotation == self.mapView.userLocation) 
{ 
    businessListingPin.canShowCallout = NO; 
    businessListingPin.pinColor = MKPinAnnotationColorRed; 
} 
else 
{ 
    businessListingPin.canShowCallout = YES; 
    businessListingPin.pinColor = MKPinAnnotationColorPurple; 
    businessListingPin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

} 

return businessListingPin; 
} 

- (void)mapView:(MKMapView *)mapView 
annotationView:(MKAnnotationView *)view 
calloutAccessoryControlTapped:(UIControl *)control 
{ 
MapDetailInfo *abc = [[MapDetailInfo alloc]init]; 
UINavigationController *nav = [[UINavigationController alloc] init]; 
[nav pushViewController:abc animated:YES]; 
} 

不確定是否重要,但這是標籤欄應用程序的一部分。任何幫助將非常感激。謝謝!

回答

0

您正在實例化一個UINavigationController(UINavigationController *nav = [[UINavigationController alloc] init];),然後將新的VC推到該目錄上,但是您絕不會將該導航控制器添加到當前視圖堆棧。只需撥打init不會將該導航控制器添加到堆棧。

當您創建UITabController時,可以爲每個選項卡創建+使用導航控制器。然後你把新的VC推到導航控制器上。

希望這會有所幫助。

**編輯

如果你已經有導航控制器的所有標籤頁,你的代碼改成這樣:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view 
calloutAccessoryControlTapped:(UIControl *)control 
{ 
    MapDetailInfo *abc = [[MapDetailInfo alloc]init]; 
    [self.navigationController pushViewController:abc animated:YES]; 
} 
+0

明白了......我已經把導航控制器的每個選項卡上....我想我不確定如何將新的VC推到該導航控制器上(對不起,我對此仍然很陌生)......謝謝! – ADZBOT

+0

[self.navigationController pushViewController:abc]我想..你的地圖VC應該有一個引用它自己的導航控制器 –

+0

得到它的工作。謝謝!我有viewControllers有點混淆。做了一些重新排序和它的工作。 – ADZBOT

相關問題