问题描述
每个人
我有问题,我一直在搜索解决方案,但找不到任何问题。我正在开发基于标签栏的应用程序。问题是我想在第一个屏幕上隐藏标签栏,然后在第一个屏幕后显示的所有其他屏幕上显示它。
有谁能请给我这个问题的最佳解决方案?
EveryoneI have a problem and I have been searching the solution but could not find any. I am working on a tab bar based app. Problem is that I want to hide tab bar at first screen and then show it on all other screens that are being displayed after first screen.Can anyone please give me the best solution for this problem?
实际情况是我有一个登录屏幕。现在我不想在此处显示标签栏,因为只有在用户登录时才会显示标签栏。当用户登录时,我希望显示标签栏以显示其内容。
Actual scenario is that I have a screen that is login screen. Now i dont want to show tab bar here as tab bar will be displayed only if the user is signed in. When user logs in, I want the tab bar to be displayed showing its contents.
最好的问候
推荐答案
如果你的标签栏控制器是你的 rootController
,您可以使用 rootController.selectedIndex = 0
来选择第一个标签栏条目,并且 rootController.selectedIndex = 1;
等等。
If you have your Tab Bar Controller as your rootController
, you can use rootController.selectedIndex =0
for selecting 1st Tab bar Item, and rootController.selectedIndex =1;
and so forth.
只要加载该特定视图,您就可以在数组中加载其他视图,然后将其添加到 rootController.selectedIndex
和 reloadInputViews
带动画。
As soon as that particular view loads, you can load the other views in an array, and then add it to the rootController.selectedIndex
and reloadInputViews
with animation.
编辑:(根据评论)
因此您有一个标签栏控制器,并且您希望在启动应用程序时显示简介和登录屏幕。如果登录成功,您想要显示标签栏控制器!这可以通过 ModalViewControllers
So you have a tab bar controller, and you want to show the introduction and the login screen while starting the App. If login is successful, you want to present the tab bar controller ! This can be done with ModalViewControllers
-
在<$ c $中完成c> ViewDidLoad 首先加载的视图(默认情况下是你的第一个标签),添加
In the
ViewDidLoad
of the view that loads up first, (it's your first tab by default), add
//Declare Introduction Screen//
IntroductionController *introductionController = [[IntroductionController alloc] initWithNibName:@"IntroductionController" bundle:[NSBundle mainBundle]];
//Give a navigation screen for your introduction screen and set it to introduction screen
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:introductionController];
navController.title = @"Introduction";
navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:navController animated:NO];
现在,只要第一个标签栏加载,您的介绍屏幕就会加载。但是加载是瞬时的,因此用户的眼睛看不到它。现在引用您的Login View Controller,如 @class LoginController
,并创建一个对象 LoginViewController * lvc;
,然后合成它。现在声明 LoginButton
并在 IBAction
Now your introduction screen would load as soon as your first tab bar loads. But the loading is instantaneous, so it's not visible to the user's eye. Now reference your Login View Controller like @class LoginController
and create an object LoginViewController *lvc;
, and synthesize it. Now declare LoginButton
and in the IBAction
-(IBAction) loginAction: (id) sender{
NSLog(@"I clicked Login");
if (self.lvc ==nil){
self.lvc = [[LoginController alloc] init ];
}
lvc.title = @"Login";
[self.navigationController pushViewController: self.lvc animated:YES];
}
并且在 LoginViewController
,如果登录成功,只需执行
And in the LoginViewController
, if Login is successful, just do
[self dismissModalViewControllerAnimated:YES];
这篇关于显示/隐藏标签栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!