【问题标题】:remove uitabbar controller [closed]删除uitabbar控制器[关闭]
【发布时间】:2012-09-17 13:15:41
【问题描述】:

我是 iPhone 开发的新手,我的问题是我的应用中有一个 UITabbar。它会在登录后显示。当我想从我的应用程序中注销时,想要返回登录视图控制器,因此应该从显示的登录视图控制器中删除标签栏。那我该怎么做呢?

我尝试隐藏标签栏,但没有奏效。

【问题讨论】:

  • “问题”?你的意思是? --"退出离子"

标签: iphone objective-c ios xcode


【解决方案1】:

在 appdelegate 中将 loginView 设为 rootView 控制器,登录后将 tabBar 设为 rootView 并在注销时从 rootView 中删除 tabBar 并将 loginView 设为 rootView。

在.h文件中

@property (nonatomic,retain) UITabBarController *yourTabBar;

在应用程序委托中添加tabBar实例-(void)addTabBar的函数将此方法添加到tabBar,不要将此作为子视图添加到窗口,只需创建即可。 并将您的 LoginView 添加为 rootViewController。

登录后添加tabBar作为子视图

TUTAppDelegate *appdelegte =(TUTAppDelegate*)[[UIApplication sharedApplication]delegate];

[[appdelegte window]addSubview:[[appdelegte yourTabBar]view]];   

在退出按钮时

TUTAppDelegate *appDelegate = (TUTAppDelegate *)[[UIApplication sharedApplication] delegate];
[[[appDelegate yourTabBar] view]removeFromSuperview]

【讨论】:

  • 登录到应用程序是在登录视图控制器中。所以 uitabbar 在那里制作,当按下登录按钮时转到带有 5 个标签栏项目的标签栏视图。所以这段代码不能在那里使用,有什么不同的想法吗?
  • 把你的tabBar放到appDelegate中,...
  • 我把登录按钮操作放在下面以及它是怎么做的
【解决方案2】:

你试过在 TabBar 前面放一个 modalViewController 吗?

UIViewController Class Reference

About View Controllers

【讨论】:

  • 所以,当您登录时将其显示为 modalview 控制器。
【解决方案3】:

这是我的登录按钮操作,如何将其放在 appdelegate 中,如果它放置 appdelegate,它如何访问登录按钮

UITabBarController *tabBarController = [[UITabBarController alloc] init ];

                    UINavigationController *statusNavigationController = [[UINavigationController alloc] init];
                    StatusViewController *statusViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil];
                    statusViewController.title = @"Status";

                      statusViewController.tabBarItem.image = [UIImage imageNamed:@"status.PNG"];
                    statusViewController.searchText=@"";
                    [statusNavigationController pushViewController:statusViewController animated:YES];


                    UINavigationController *messageNavigationController = [[UINavigationController alloc] init];
                    MessageViewController *messageViewController = [[MessageViewController alloc] initWithNibName:@"MessageViewController" bundle:nil];
                    messageViewController.title = @"Messages";
                    messageViewController.tabBarItem.image = [UIImage imageNamed:@"message.PNG"];

                    messageViewController.searchText=@"";
                    [messageNavigationController pushViewController:messageViewController animated:YES]

                    [tabBarController addChildViewController:statusNavigationController];
                    [tabBarController addChildViewController:messageNavigationController
                    [self.navigationController pushViewController:tabBarController animated:YES];

【讨论】:

  • 制作tabBarController的属性
【解决方案4】:

在不同的View或Xib中设置登录页面和下一页。

给第 2 个 Xib 的 UITabbar。

当 logOut 指向第一个 View 时。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多