iphone - UITabBarController 与 UINavigationController "more"选项卡问题

标签 iphone uinavigationcontroller uitabbarcontroller

UITabBarController 与 UINavigationController“更多”选项卡问题

在 UITabBarController 中使用 UINavigationController 时出现问题。我有一个包含 6 个项目的 TabBar。当然,会出现一个标准项“更多”,并且有两个 UINavigationController 不适合 TabBar。问题的核心是:当我处理可见项目(前四个)时,可以将 UIViewController 推送到 UINavigationController 中:

[self.navigationController PushViewController:userDataViewController 动画:YES];

如果您在“更多”中调用并以这种方式重新排列项目,则在调用 userDataViewController 时,可见的 UINavigationController 会进入“更多”中。这个 userDataViewController 是最后一个,它已进入堆栈,并且“后退”按钮会返回到“更多”,但不会返回到 userDataViewController 出现之前的 Controller 。

据我所知,实际上选择器pushViewController是从“more”调用的,它将我的UINavigationController推送到堆栈中,这不好。也许有人遇到过这样的问题并可以帮助我解决它?

谢谢转发。

最佳答案

一个可能的解决方案是在用户保存选项卡栏配置更改之前强制 UINavigationController 返回其 Root View Controller 。为此,请在标签栏 Controller 的委托(delegate)中实现以下方法:

- (void)tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed {
    if (changed) {
        NSLog (@"User has rearranged tab bar items");

        for (UIViewController *controller in tabBarController.viewControllers) {
            if ([controller isKindOfClass:[UINavigationController class]]) {
                [((UINavigationController *)controller) popToRootViewControllerAnimated:NO];
            }
        }
    }
}

关于iphone - UITabBarController 与 UINavigationController "more"选项卡问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1596618/

相关文章:

ios - 如何从其自己的 subview Controller 中解散模态 uitabbarcontroller

objective-c - UIViewController 可以推送 UITabBarController 吗?

iphone - iOS - 多 View 应用程序 - 内存问题

iphone - 如何在 iOS 中对彩色视频应用黑白效果

ios - 通过更改导航栏的颜色从一个 View Controller 过渡到另一个 View Controller

ios - 如何将导航 Controller 放入标签栏 Controller 中?

iphone - 确切的 iOS 5.0 在哪里存储用户上传的文件?没有 "Do Not backup"标志

ios - NSURLCredential 创建返回 null

ios - 执行 segue 后,嵌入式导航栏在 iOS 7(小屏幕)上消失,但在 iOS 9(大屏幕)上不消失

iphone - 带有 View 的 TabBar 应用程序,该 View 上有一个 UIButton 以转到 TabBar 之外的另一个 View