我如何进入UINavigationController兄弟视图?

时间:2012-04-16 20:55:57

标签: ios uitableview uinavigationcontroller navigation

我有一个导航控制器....和tableview一样:

项目A>
项目B>
项目C>
项目D>
地图>

单击表格单元格会转到项目X的详细信息视图。地图视图显示项目A-D的精确点。注释标注上有一个公开按钮。披露按钮代码执行此操作:

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

此时我想要做的是在弹出地图视图后推送项目X的详细视图。这样做的正确方法是什么?

2 个答案:

答案 0 :(得分:0)

您的方法不正确。你有一个表格视图:

项目A> (单击时按下项目A的详细信息视图)DetailsView(A)
项目B> (单击时按下项目B的详细信息视图)DetailsView(B)
项目C> (单击时按下项目C的详细信息视图)DetailsView(C)
项D> (单击时按下项目D的详细信息视图)DetailsView(D)
地图> (点击时按下地图视图)地图视图> (当您单击公开按钮时,您需要按DetailsView以获取相应的项目并更深入一级)

答案 1 :(得分: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]];

}

相关问题