【问题标题】:Using more than 1 UINavigationController and only one UITabBarController使用超过 1 个 UINavigationController 且仅使用一个 UITabBarController
【发布时间】:2012-09-13 06:01:27
【问题描述】:

我在管理多个UINavigationControlller 时遇到问题。

我有一个UITabBar,在每个标签中我都有一个单独的UINavigationController。所以如果我通过

切换UITabBar
tabBar.selectedIndex = i; // where i is index of tabbar.

当我返回上一个标签时

tabBar.selectedIndex = previousIndex;

我转到UINavigationController 的根目录,而不是我之前离开的视图控制器。

我想转到视图控制器,从该控制器跳转到另一个选项卡,而不调用 -viewDidLoad:-viewWillAppear:

我需要一个显示UINavigationController 或我的viewController 的方法。

【问题讨论】:

  • 这是 UITabBar 的默认功能,除非我们对显示 rootView 进行任何更改...你可能会在 tabBarDelegate 中写一些东西来显示 rootView..
  • 您是否使用this 的任何tabbarDelegate 方法,请分享代码
  • 好的,我正在检查我的 tabbardelegate。 @vishy

标签: iphone ios xcode uinavigationcontroller uitabbarcontroller


【解决方案1】:

当您尝试切换选项卡时,将在您的 AppDelegate.m 文件中实现以下方法

- (BOOL)tabBarController:(UITabBarController *)tbc shouldSelectViewController:(UIViewController *)viewController {

}

在你的 appDelegate 类中指定为你的 tabbarcontroller 的 delagate

ie.(TabBarController.delegate = self) 在 appDidFinishLaunching 方法中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-03
    • 2017-05-24
    • 1970-01-01
    • 2012-01-10
    • 1970-01-01
    • 2012-11-14
    • 1970-01-01
    相关资源
    最近更新 更多