简体   繁体   English

标签栏控制器通过应用程序委托访问当前标签的活动导航控制器

[英]Tabbar controller accessing active navigation controller of current tab through app delegate

I have the following setup. 我有以下设置。 I have a TabBarController with three NavigationControllers in it. 我有一个带有三个NavigationControllers的TabBarController。 What I want to do is the following: 我想做的是以下几点:

I have a mapview with annotations on it and a button on the annotation, I implemented the delegate method that fires when the annotation button is tapped. 我有一个带注解的mapview和注解上的按钮,我实现了在点击注解按钮时触发的委托方法。 My problem is that the delegate for my mapview is also a subview of the mapview 我的问题是我的mapview的委托也是mapview的子视图

[self.mapView addSubview:self];
[self.mapView setRegion:region];
[self.mapView setDelegate:self];

This is in a custom class that I use to draw routes on my mapview. 这是一个自定义类,用于在地图视图上绘制路线。

In other words the following method is in the custom class which is the delegate of my mapview 换句话说,以下方法位于自定义类中,该类是我的mapview的委托

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    Helper *myHelper = [Helper sharedManager];
    StationInfo *myViewController = [[StationInfo alloc] initWithNibName:@"StationInfo" bundle:[NSBundle mainBundle]];
     myViewController.station = [myHelper.stations objectAtIndex:[myHelper.stations indexOfObject:[view annotation]]];
    GautrainiPhoneAppDelegate *del = (GautrainiPhoneAppDelegate *)[UIApplication sharedApplication].delegate;
    //missing code to push the controller onto the navigation controller that is on the active tab in the tabBarcontroller

}

So how can I push a view controller onto the navigation stack of the active tab using the app delegate that contains my tabbarcontroller 因此,如何使用包含我的tabbarcontroller的应用程序委托将视图控制器推到活动选项卡的导航堆栈上

Figured out a viable solution for what I wanted to do. 为我想做的事找到可行的解决方案。 I created an outlet for the navigationcontroller I was trying to access and then just pushed my view 我为试图访问的导航控制器创建了一个插座,然后推送了我的视图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM