Ios 同时使用UIAbbarController和UINavigationController

Ios 同时使用UIAbbarController和UINavigationController,ios,objective-c,iphone,uinavigationcontroller,uitabbarcontroller,Ios,Objective C,Iphone,Uinavigationcontroller,Uitabbarcontroller,在选项卡栏视图之后的视图中单击时,使2个选项卡的行为类似于UINavigationController的最佳做法或最佳方式是什么 我是否为每个选项卡制作UINavigationController 选项卡栏的创建方式如下: // Create the tab bar text and images AViewController *viewA = [[AViewController alloc] init]; BViewController *viewB = [[BViewController

在选项卡栏视图之后的视图中单击时,使2个选项卡的行为类似于UINavigationController的最佳做法或最佳方式是什么

我是否为每个选项卡制作UINavigationController

选项卡栏的创建方式如下:

// Create the tab bar text and images
AViewController *viewA = [[AViewController alloc] init];
BViewController *viewB = [[BViewController alloc] init];

UITabBarItem *tabA = [[UITabBarItem alloc] initWithTitle:@"A" image:[UIImage imageNamed:@"a.png"] tag:1];
UITabBarItem *tabB = [[UITabBarItem alloc] initWithTitle:@"B" image:[UIImage imageNamed:@"b.png"] tag:2]

viewA.tabBarItem = tabA;
viewB.tabBarItem = tabB;

NSArray* controllers = [NSArray arrayWithObjects:viewA, viewB, nil];
self.viewControllers = controllers;

对于导航,您需要为每个控件创建UINavigationController,如下所示

更新:立即尝试

AViewController *viewA = [[AViewController alloc] init];
BViewController *viewB = [[BViewController alloc] init];

UINavigationController *navA = [[UINavigationController alloc]initWithRootViewController:viewA];
UINavigationController *navB = [[UINavigationController alloc]initWithRootViewController:viewA];

UITabBarItem *tabA = [[UITabBarItem alloc] initWithTitle:@"A" image:[UIImage imageNamed:@"a.png"] tag:1];
UITabBarItem *tabB = [[UITabBarItem alloc] initWithTitle:@"B" image:[UIImage imageNamed:@"b.png"] tag:2]

tabA.tabBarItem = tabA;
tabB.tabBarItem = tabB;

NSArray* controllers = [NSArray arrayWithObjects:navA, navB, nil];
self.viewControllers = controllers;

尝试此操作

是,在每个选项卡中单独设置
UINavigationController
。每个选项卡都位于独立的视图控制器堆栈中。它们不应共享任何视图控制器层次结构。通常情况下,我会拖出一个“选项卡栏控制器”和两个“导航控制器”,并将两个导航控制器连接为选项卡栏控制器的子视图控制器。如果选项卡栏不在appDelegate中,这有什么关系?没什么关系,但这里需要为下一个控制器创建UIAbbarController