あなたは怒鳴るようにそれを行うことができます..
UITabBarController
最初にAppDelegate
クラス内のオブジェクトを作成し、次のapplicationDidFinishLaunching:
ようにメソッドに割り当てます..
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController2 = [[[UITabBarController alloc]init]autorelease];
self.tabBarController3 = [[[UITabBarController alloc]init]autorelease];
以下のように別のタブを RootViewController として設定するためのメソッドを作成した後...
-(void)setRootViewControllerTab1{
UIViewController *viewController1, *viewController2;
UINavigationController *navviewController1 , *navviewController2,;
viewController1 = [[[HomeViewController alloc] initWithNibName:@"viewController1" bundle:nil] autorelease];
navviewController1=[[UINavigationController alloc]initWithRootViewController:viewController1];
navviewController1.title = @"Title1";
viewController2 = [[[HowItWorksViewController alloc] initWithNibName:@"viewController2" bundle:nil] autorelease];
navviewController2=[[UINavigationController alloc]initWithRootViewController:viewController2];
navviewController2.title = @"Title2";
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navviewController1, navviewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
}
-(void)setRootViewControllerTab2{
UIViewController *viewController3, *viewController4;
UINavigationController *navviewController3 , *navviewController4;
/////TAB 2/////***********
viewController3 = [[[CUHomeViewController alloc] initWithNibName:@"viewController3" bundle:nil] autorelease];
navviewController3=[[UINavigationController alloc]initWithRootViewController:viewController3];
navviewController3.title = @"Title3";
viewController4 = [[[CUFavouritiesViewController alloc] initWithNibName:@"viewController4" bundle:nil] autorelease];
navviewController4=[[UINavigationController alloc]initWithRootViewController:viewController4];
navviewController4.title = @"Title4";
self.tabBarController2.viewControllers = [NSArray arrayWithObjects:navviewController3, navviewController4, nil];
self.window.rootViewController = self.tabBarController2;
[self.window makeKeyAndVisible];
}
AppDelegate
以下のようなオブジェクトで上記のメソッドを呼び出します...
例:メソッドでその時点でクリックされた button1 は、次のコードを記述します...
- (IBAction)btn1_Clicked:(id)sender{
AppDelegate *objApp = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[objApp setRootViewControllerTab1];
}