我UITabBarController
在视图控制器上使用,即launchviewcontroller
包含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];
}
现在,当用户转到第 4 个选项卡以从应用程序中注销时,我设置了一个按钮以再次登录,通过在按钮单击上添加代码来重定向到登录视图:
-(void)ClickOnLogin
{
LoginViewController *LoginViewOb=[[LoginViewController alloc]init];
LoginViewOb.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:LoginViewOb animated:YES];
[LoginViewOb release];
}
但是当登录视图被加载时,前一个视图仍然在登录视图的后面。如何从背景中删除此视图。