0

I am using UITabBarController on a view controller i.e launchviewcontroller which contains code on loadview as below:

- (void)loadView
{
   viewControllers=[[NSMutableArray alloc]initWithCapacity:2];
    tabBarController=[[UITabBarController alloc]init];  
   MyProfileViewController *view1=[[MyProfileViewController alloc]init];
   localNavigationController=[[UINavigationController alloc]initWithRootViewController:view1];
   localNavigationController.navigationBar.alpha=1.0;
   //   localNavigationController.navigationBar.tintColor=[UIColor colorWithRed:0.65 green:0.84 blue:0.88 alpha:1];
   localNavigationController.navigationBar.tintColor=[UIColor blackColor];

   //    localNavigationController.navigationBar.
   [viewControllers addObject:localNavigationController];
   [view1 release];
   [localNavigationController release];
   localNavigationController=nil;


   TodaysPicksViewController *view2=[[TodaysPicksViewController alloc]initWithLeagueType:@"CFL Football"];
   localNavigationController=[[UINavigationController alloc]initWithRootViewController:view2];
   localNavigationController.navigationBar.alpha=1.0;
   localNavigationController.navigationBar.tintColor=[UIColor blackColor];
   [viewControllers addObject:localNavigationController];
   [view2 release];
   [localNavigationController release];
   localNavigationController=nil;


   Rules_PoliciesViewController *view3=[[Rules_PoliciesViewController alloc]init];
   localNavigationController=[[UINavigationController alloc]initWithRootViewController:view3];
   localNavigationController.navigationBar.alpha=1.0;
   localNavigationController.navigationBar.tintColor=[UIColor blackColor];
   [viewControllers addObject:localNavigationController];
   [view3 release];
   [localNavigationController release];
   localNavigationController=nil;

    LogoutViewController *view4=[[LogoutViewController alloc]init];
   localNavigationController=[[UINavigationController alloc]initWithRootViewController:view4];
   localNavigationController.navigationBar.alpha=1.0;
   localNavigationController.navigationBar.tintColor=[UIColor blackColor];
   [viewControllers addObject:localNavigationController];
   [view4 release];
   [localNavigationController release];
   localNavigationController=nil;

   appDel=[[UIApplication sharedApplication]delegate];

   tabBarController.viewControllers=viewControllers;
   [appDel.window addSubview:tabBarController.view];
   [viewControllers release];

}

Now as user goes to 4th tab to logout from app I have set a button to login again redirected to login view by adding code on button click as:

-(void)ClickOnLogin
{
   LoginViewController *LoginViewOb=[[LoginViewController alloc]init];
   LoginViewOb.hidesBottomBarWhenPushed = YES;
   [self.navigationController pushViewController:LoginViewOb animated:YES];
   [LoginViewOb release];
}

but as login view is loaded the previous view is still at back of login view. How can I remove this view from background.

Baddu
  • 290
  • 2
  • 11
Priyanka
  • 511
  • 8
  • 24
  • you should disable back button on login view – Baddu Jul 10 '13 at 10:44
  • [How can I pop a view from a UINavigationController and replace it with another in one operation?](http://stackoverflow.com/q/410471/1041847) – Alexander Jul 10 '13 at 10:44
  • in appdelegate u have load every time login page then one's user login then u can load tabbar – Anjaneyulu Jul 10 '13 at 10:50
  • what is your code of Logout button?? please post that method with code.. – Paras Joshi Jul 10 '13 at 10:53
  • as user licks on logout tab at the bottom he will see the label "you have successfully logout.Click here to login".code that i've implemented is in my question above. – Priyanka Jul 10 '13 at 11:01
  • You should use popToRootViewController on your logout button click and push the LoginViewController again, but this time with label "Click here to login". – HRM Jul 10 '13 at 11:47

1 Answers1

0

you should disable back button on login view

- (void)viewWillAppear:(BOOL)animated
{ 
    self.navigationItem.leftBarButtonItem=nil;
    self.navigationItem.hidesBackButton=YES;
    [super viewWillAppear:animated];

}
DD_
  • 7,230
  • 11
  • 38
  • 59
Baddu
  • 290
  • 2
  • 11