2013-07-10 52 views
0

我的视图控制器上使用UITabBarControllerlaunchviewcontroller其含有上loadview如下代码:如何删除背景视图

- (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]; 

}

现在,作为用户进行到第四突出部从应用程序我注销设置了按钮登录再次重定向由上按钮点击添加代码作为登录视图:

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

但作为登录视图是负载ed先前的视图仍然位于登录视图的后面。我怎样才能从后台删除这个视图。

+0

你应该禁用后退按钮上登录视图 – Baddu

+0

禁用后退按钮(HTTP [我如何从一个UINavigationController弹出一个视图和一个操作与另一个替换吗?] //stackoverflow.com/q/410471/1041847) – Alexander

+0

在appdelegate你有加载每次登录页面,然后一个人的用户登录然后你可以加载标签栏 – Anjaneyulu

回答

0

你应该登录查看

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

} 
+0

没有它没有工作 – Priyanka

+0

我的想法是正确的,后退按钮困扰着你吗? – Baddu

+0

no.i已创建了一个用于注销的视图控制器,它显示标签,显示您已成功注销并单击登录按钮以再次登录 – Priyanka