有没有一种方法可以检索标签栏 Controller 的当前可见导航 Controller ?

例如,我的程序中有2个标签栏(每个都有一个导航 Controller ),如下所示

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
   //Method is called when user clicks on a hyperlink in one of view controllers
    NSDictionary *dict = [self parseQueryString:[url query]];
    NSString *userID = [dict objectForKey:@"id"];
    NSString *navconTitle = [dict objectForKey:@"navcon"];


    //intention is to push a view controller onto the CURRENT navigation stack
    [navcon pushViewController:someViewController animated:YES];

    }
}

return YES;
}

谁能告诉我如何确定当前的导航 Controller ,以便可以将更多的 View Controller push 其中?

最佳答案

使用 UITabBarController s selectedViewController属性。

navcon = (UINavigationController*)myTabBarController.selectedViewController;
[navcon pushViewController:someViewController animated:YES];

07-26 09:38