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/