gpt4 book ai didi

ios - 如何在 Ios 中推送 rootviewcontroller

转载 作者:行者123 更新时间:2023-11-28 20:15:46 27 4
gpt4 key购买 nike

我从 rootviewController(UInavigation Controller )推送新的 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];

你可以看到这张图片: enter image description here

最佳答案

使用 popToRootViewControllerAnimated 方法代替 pushViewController:

[self.navigationController popToRootViewControllerAnimated:animated];

关于ios - 如何在 Ios 中推送 rootviewcontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18150882/

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