【问题标题】:Navigate back to table of tab options every time 'more' option is clicked每次单击“更多”选项时,导航回选项卡选项表
【发布时间】:2014-03-18 06:18:25
【问题描述】:

我的 iPhone 应用程序中有一个 UITabBar 应用程序,其中包含 8 个选项卡。

  1. 当我单击“更多”选项时,我会看到剩余的选项卡并导航到相应的视图。
  2. 如果我单击可见的第二个或第三个选项卡并返回“更多”选项卡,我应该会再次看到剩余选项卡选项表,而不是导航的子视图。

那么每次点击“更多”时,我该如何重置回“更多”标签表?

我在 AppDelegate.m 中尝试了以下委托方法

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"controller class: %@", NSStringFromClass([viewController class]));
    NSLog(@"controller title: %@", viewController.title);


    if (viewController == tabBarController.moreNavigationController)
    {
        tabBarController.moreNavigationController.delegate = self;
    }
    if ([viewController isKindOfClass:[UINavigationController class]])
    {
        [(UINavigationController *)viewController popToRootViewControllerAnimated:NO]; //All viewControllers are UINavigationController classes in my app
    }

}

【问题讨论】:

  • 那么,问题出在哪里?
  • @A-Live 每次点击“更多”时如何重新设置回“更多”标签表?

标签: ios iphone objective-c uitabbarcontroller uitabbar


【解决方案1】:
@property(nonatomic, readonly) UINavigationController *moreNavigationController

负责More项的导航,当你想导航到该项的根目录时需要用到它:

[tabBarController.moreNavigationController popToRootViewControllerAnimated:NO];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多