0

我从 rootviewController(UInavigation 控制器)推送新的 StatusViewController(我以编程方式在其中创建了 UITabbarViewController)。现在,我想点击注销按钮,它推送 rootviewcontroller 但我使用了下面的代码,它推送 rootviewcontroller 很好,但它仍然是底部的标签栏。

这段代码调用 rootviewcontroller:

    LoginTab *loginView = [[LoginTab alloc] init];
    [self.navigationController pushViewController:loginView animated:YES];
    [loginView release];

这段代码是在 StatusViewController 中创建的 UItabbarcontroller:

self.tab=[[UITabBarController alloc]init];

UploadTab *uploadview=[[UploadTab alloc]initWithNibName:nil bundle:nil];
UINavigationController *uploadTabItem = [[[UINavigationController alloc] initWithRootViewController: uploadview] autorelease];
uploadview.title=@"Uploading";
uploadview.tabBarItem.image=[UIImage imageNamed:@"Uploading.png"];
self.title = @"FirstViewControllerTitle";

//SecondViewController
ConvertTab *convertView=[[ConvertTab alloc]initWithNibName:nil bundle:nil];
UINavigationController *convertTabItem = [[[UINavigationController alloc] initWithRootViewController: convertView] autorelease];
convertView.title=@"Convert";
convertView.tabBarItem.image=[UIImage imageNamed:@"Convert.png"];

//ThirdViewController
CompletedTab *completedView=[[CompletedTab alloc]initWithNibName:nil bundle:nil];
UINavigationController *completedTabItem = [[[UINavigationController alloc] initWithRootViewController: completedView] autorelease];
completedView.title=@"Completed";
completedView.tabBarItem.image=[UIImage imageNamed:@"Completed.png"];
UIBarButtonItem * LogoutItem= [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Logout.png"] style:UIBarButtonItemStylePlain target:self action:@selector(logout)];

self.navigationItem.rightBarButtonItem = LogoutItem;
self.tab.viewControllers=[NSArray arrayWithObjects:uploadTabItem,convertTabItem, completedTabItem, nil];

// [self.view insertSubview:self.tab.view belowSubview: uploadview.view];
[self presentModalViewController:self.tab animated:NO];

你可以看到这张图片: 在此处输入图像描述

4

2 回答 2

3

使用popToRootViewControllerAnimated方法代替pushViewController

[self.navigationController popToRootViewControllerAnimated:animated];
于 2013-08-09T16:04:55.820 回答
0

您的层次结构似乎不正确。您的标签栏控制器应该是根视图控制器。对于每个选项卡,您可以有一个导航控制器,它有自己的控制器来推送和弹出。也就是说,您的标签栏将始终可见,因为这是您拥有基于标签栏的应用程序时所期望的行为。如果要呈现不显示标签栏的视图,则需要将该视图控制器作为模式视图控制器呈现在标签栏控制器的顶部。

于 2013-08-09T16:37:25.810 回答