人们如何在UITabBarController下弹出其UINavigationController堆栈? [英] How are people popping their UINavigationController stacks under a UITabBarController?

查看:56
本文介绍了人们如何在UITabBarController下弹出其UINavigationController堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个UINavigationControllers,每个分配给一个UITabBarController中的选项卡.每个UINavigationController都管理一个UIViewController,该UIViewController本身可以分层地分支到其下面的其他UIViewController中.

I have four UINavigationControllers assigned each to a tab in a UITabBarController. Each UINavigationController manages a UIViewController, which may itself branch out into other UIViewControllers below it hierarchally.

我的问题是,如果用户在一个选项卡下导航到一个UIViewController,该UIViewController分层地位于由UINavigationController管理的主UIViewController之下,然后用户按下另一个选项卡,然后返回到原始标签,如何使用户看到由UINavigation控制器管理的主UIViewController?,而不是他离开的页面?

My question is, in a case in which a user, under one tab, has navigated to a UIViewController that hierarchally BELOW the main UIViewController managed by the UINavigationController, and then the user pushes a different tab, and then goes back to the original tab, HOW can I make it so that the user is presented with the main UIViewController managed by the UINavigation controller? and not the page where he left off?

UITabBarController是在IB中设置的

UITabBarController is set up in IB

推荐答案

实施UITabBarControllerDelegate协议,并在通知您的委托人用户选择了其他选项卡时弹出到根控制器.

Implement the UITabBarControllerDelegate protocol and pop to the root controller whenever your delegate is notified that the user has selected a different tab.

类似的东西:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    [viewController.navigationController popToRootViewControllerAnimated:YES];
}

上面的代码应弹出到任何导航控制器的根控制器,该导航控制器是新选择的选项卡的主视图控制器.您可以尝试在应用程序委托中实现协议.并且不要忘记将应用程序委托实际分配为选项卡栏控制器的委托.

The code above should pop to the root controller of any navigation controller that is the main view controller of the newly selected tab. You could try implementing the protocol in your application delegate. And do not forget to actually assign the app delegate as the tab bar controller's delegate.

这篇关于人们如何在UITabBarController下弹出其UINavigationController堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆