私はUITabBarController
View Controllerで使用しています。つまり、以下の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];
}
ただし、ログイン ビューが読み込まれると、以前のビューはまだログイン ビューの後ろにあります。このビューをバックグラウンドから削除するにはどうすればよいですか。