0

我正在开发一个包含登录页面的应用程序。第一个页面应该是登录页面(带有视图控制器)。用户登录后,我将显示另一个视图,我需要显示一个标签栏,当用户注销时,必须显示相同的登录屏幕。我怎样才能做到这一点?

4

3 回答 3

2

TabbarController您在您的班级中创建。AppDelegete当用户成功登录时,您将设置Appdelegete TabbarControllerRootViewController您的窗口。

AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
[appDelegate.window setRootViewController:appDelegate.tabBarController];
于 2013-05-13T07:48:02.970 回答
1

I have done this type of project but i have made custom tabbar as requirement. After login user have to go to profile page then i use 2nd method but before checking the user has loggedin or not by this 1st method-

if([AppHelper userDefaultsForKey:@"user_id"].length>0)
    {
        [[AppDelegate getAppdelegate] createTabBar];
    }

then you should you this -

-(void)createTabBar
{

    self.tabBarController=[[RXCustomTabBar alloc] init]; 
    self.tabBarController.customizableViewControllers = nil;   

    Home *homeObj =  [[Home alloc] initWithNibName:@"Home" bundle:nil];
    UINavigationController *tab1Controller = [[UINavigationController alloc] initWithRootViewController:homeObj];     

    ChatList *chatListObj = [[ChatList alloc] initWithNibName:@"ChatList" bundle:nil];
    UINavigationController *tab2Controller = [[UINavigationController alloc] initWithRootViewController:chatListObj];


    Settings *settingObj = [[Settings alloc] initWithNibName:@"Settings" bundle:nil];
    UINavigationController *tab3Controller = [[UINavigationController alloc] initWithRootViewController:settingObj];  

    self.tabBarController.viewControllers = [NSArray arrayWithObjects: tab1Controller, tab2Controller,tab3Controller, nil];
    self.tabBarController.selectedIndex=0;
    self.tabBarController.delegate = self;
    [self.tabBarController selectTab:0];

    self.window.backgroundColor=[UIColor clearColor];
    self.tabBarController.view.backgroundColor=[UIColor clearColor];

    [self.window addSubview: self.tabBarController.view];


}

After this if you have any problem I will be here. Hope this helps.

于 2013-05-13T07:59:54.850 回答
0

我将通过模态视图显示登录屏幕。在这种情况下,您可以在界面构建器中为第一个视图实现选项卡栏。

于 2013-05-13T07:47:52.300 回答