objective-c - 如何从标签栏 Controller 获取 'current' 导航 Controller

标签 objective-c ios uinavigationcontroller uitabbarcontroller

是否有一种方法可以检索标签栏 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 推送到它上面?

最佳答案

使用 UITabBarControllers selectedViewController 属性。

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

关于objective-c - 如何从标签栏 Controller 获取 'current' 导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6441153/

相关文章:

iphone - 在 View Controller 、iOS 应用程序之间切换

ios - 在 UILabel Word Wrapped 属性后添加 '...'

iOS WatchKit - 如何检测 watch 上的后退按钮何时被按下?

ios - 使用 segues 在 NavigationController 中嵌入 UIViewController

iphone - Objective-C 中不常用的符号

ios - 以编程方式拍摄 X 张照片

iOS,reloadRowsAtIndexPaths - 在我将新对象添加到其数据源后崩溃

ios - 在 XCode 中提交文件

ios - 查询应用程序的购买历史记录列表

iphone - 单击按钮并加载导航 Controller