2012-04-16 17 views
0

我有一個導航控制器....和tableview中像這樣:如何進入UINavigationController同級視圖?

項A>
項目B>
項目C>
項d>
地圖>

點擊一個表格單元會帶您進入項目X的細節視圖。地圖視圖顯示項目A-D的精確點。註釋標註上有一個公開按鈕。披露按鈕代碼做到這一點:

[self.navigationController popViewControllerAnimated:true]; 
//Now what??? 

我想在這一點上做的是推動商品X的詳細視圖彈出地圖視圖後。什麼是正確的方法來做到這一點?

+1

我的天哪......我想我想通了。我需要將披露按鈕的委託設置爲表視圖控制器而不是地圖視圖控制器?!?咄。 – Bryan 2012-04-16 21:01:16

回答

0

不自豪這個,但是......我確實想出了一個解決方案。我根據用於設置tableview的數組的索引爲單個註釋設置標籤值。

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { 
//So, we clicked that disclosure button 
//TODO: This is really hacky... What is proper way to do this? 
ServicesViewController *vc = [self.navigationController.viewControllers objectAtIndex:1]; 
[vc infoButtonPressed:control.tag]; 

}

現在ServicesViewController我們可以這樣做:

- (void) infoButtonPressed:(NSInteger) index { 

// decided against this first step, as graver's answer explains, it does not really make sense 
//[self.navigationController popViewControllerAnimated:false]; 

//index should be nav array index we want to push 
//so simulate a table-row click 
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]]; 

}

0

您的方法不正確。你有一個表視圖:

項目A>(點擊時你推詳細查看項目A)DetailsView控件(A)
項目B>(點擊後你把詳細信息視圖B項)DetailsView控件(B)
項目C>(點擊時,您按下項目C的詳細視圖)DetailsView(C)
項目D>(點擊時,您推送項目D的詳細信息視圖)詳細信息(D)
地圖> )地圖視圖>(當你點擊披露按鈕,你需要推動DetailsView的適當項目,並進一步深入)

+0

欣賞迴應,但不是我所問的!我想我明白了。我原來的評論或多或少引導我回答,我將發佈。 – Bryan 2012-04-18 02:02:20

+0

但是......話雖如此,我同意所需的行爲是不正確的。你描述的行爲更符合標準的iOS UI慣例。這不是規範要求的。 – Bryan 2012-04-18 02:04:08

相關問題