gpt4 book ai didi

ios - UINavigationController 堆栈 UITabBarControllers 哪些堆栈其他 UINavigationControllers?

转载 作者:行者123 更新时间:2023-11-28 22:49:25 26 4
gpt4 key购买 nike

我读到在 iOS 应用程序中有这样的结构是不好的。但是,如果应用程序有很多 UINavigationControllerUITabBarController 怎么办?但是一个UINavigationBar和一个UITabBar总是只显示?其他 UINavigationBarUITabBar 被隐藏。

已编辑

例如,在基于导航的应用程序中,我调用这段代码:

- (IBAction)openTabsController:(id)sender {        

tabOneController *tabOneViewContr = [[[tabOneController alloc] initWithNibName:@"tabOneController" bundle:nil] autorelease];
UINavigationController *tabOneNavContr = [[UINavigationController alloc] initWithRootViewController:tabOneViewContr];

tabTwoController *tabTwoViewContr = [[[tabTwoController alloc] initWithNibName:@"tabTwoController" bundle:nil] autorelease];
UINavigationController *tabTwoNavContr = [[UINavigationController alloc] initWithRootViewController:tabTwoViewContr];


UITabBarController *tabContr = [[[UITabBarController alloc] init] autorelease];
tabContr.viewControllers = [NSArray arrayWithObjects:tabOneNavContr,tabTwoNavContr, nil];
sel.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:tabContr animated:YES];
}

调用此方法后,我有两个 UINavigationController 和一个 UITabBarController。同时我在屏幕上有一个 UINavigationBar 和一个 UITabBar

已编辑

大致方案。

enter image description here

从一开始我们就有一个 UINavigationController,它允许在 View (圆圈)之间导航。然后在按下 UITabBar 后出现并允许在 View 之间切换。带有两个小矩形的矩形是带有 UITabBar 和 2 个 UITabBarItem 的 View 。当我们按下任何 UITabBarItem 时,另一个 UIView 就会出现。在这个 UIView 中,我们可以按下一些按钮,调用另一个带有另一个 UITabBar 的 View 。如果当前 UITabBar 未被另一个 UITabBar 隐藏,则当前 UITabBar 在推送后可见。现在更清楚了吗?上面的代码几乎完美(除了一些动画,不包括 Apple 的限制)

最佳答案

加尔戈,

我不确定我是否理解您的问题,但苹果文档很清楚。如果你使用 - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated 它说 viewController:

cannot be an instance of tab bar controller and it must not already be on the navigation stack.

既然你这样做了

[self.navigationController pushViewController:tabContr animated:YES];

您正在导航堆栈中推送标签栏 Controller 实例。

如果您添加您要实现的结构,也许我可以帮助您找到另一个解决方案。

希望对您有所帮助。

关于ios - UINavigationController 堆栈 UITabBarControllers 哪些堆栈其他 UINavigationControllers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12313439/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com