开发者

Tabbar controller accessing active navigation controller of current tab through app delegate

开发者 https://www.devze.com 2023-03-30 15:40 出处:网络
I have the following setup. I have a TabBarController with three NavigationControllers in it. What I want to do is the following:

I have the following setup. I have a TabBarController with three NavigationControllers in it. 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. My problem is that the delegate for my mapview is also a subview of the 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 foll开发者_如何学Goowing method is in the custom class which is the delegate of my 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号