问题描述
我是iPhone开发新手,我的问题是我的应用程序中有一个 UITabbar
。它将在登录后显示。当我想从我的应用程序注销时,想要返回到登录视图控制器,因此应该从显示的登录视图控制器中删除标签栏。那我该怎么做?
I am new to iPhone development, my problem is that I have a UITabbar
in my app. It will display after sign in. when I want to log out from my app, want to go back to the sign in view controller, so the tab bar should be removed from the sign in view controller shown. So how do I do that?
我试图隐藏标签栏,但这不起作用。
I tried hiding tab bars, but that didn't work.
推荐答案
在appdelegate中将loginView作为rootView控制器,登录后将tabBar作为rootView,在注销时从rootView中删除tabBar,并将loginView作为rootView。
In appdelegate make your loginView as rootView controller, after login make your tabBar as rootView and at the time of logout remove tabBar from rootView and make loginView to as rootView.
或
在.h文件中
@property (nonatomic,retain) UITabBarController *yourTabBar;
使函数添加tabBar实例 - (void)addTabBar
在app delegate中这个方法将你的所有视图添加到tabBar,不要将它作为subView添加到窗口,只需创建它。
并将rootView添加为rootViewController。
Make function to add tabBar instance -(void)addTabBar
in app delegate this method add your all view to tabBar, Dont add this as subView to window,just make it.And add your LoginView as rootViewController.
登录后将tabBar添加为subView
after login add tabBar as subView
TUTAppDelegate *appdelegte =(TUTAppDelegate*)[[UIApplication sharedApplication]delegate];
[[appdelegte window]addSubview:[[appdelegte yourTabBar]view]];
和退出按钮
TUTAppDelegate *appDelegate = (TUTAppDelegate *)[[UIApplication sharedApplication] delegate];
[[[appDelegate yourTabBar] view]removeFromSuperview]
这篇关于删除uitabbar控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!