2013-01-25 25 views
-4

我不知道如何初始化包含標籤欄的視圖控制器,並且標籤欄中有2個視圖控制器?如何初始化一個帶有標籤欄的視圖控制器?

我有一個current_view_controller,一個OrderPanel,一個firstViewController和一個SecondViewController。

firstViewController和SecondViewController是OrderPanel中的選項卡。我如何正確初始化並在current_view_controller中調用OrderPanel?

這是建立Tab鍵切換到視圖控制器

#import "OrderPanel.h" 

    #import "OrderPanelFirstViewController.h" 

    #import "OrderPanelSecondViewController.h" 

    @implementation OrderPanel 

    @synthesize window = _window; 
    @synthesize tabBarController = _tabBarController; 

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:   (NSDictionary *)launchOptions 
    { 
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
// Override point for customization after application launch. 
UIViewController *viewController1, *viewController2; 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    viewController1 = [[OrderPanelFirstViewController alloc]  initWithNibName:@"OrderPanelFirstViewController_iPhone" bundle:nil]; 
    viewController2 = [[OrderPanelSecondViewController alloc]  initWithNibName:@"OrderPanelSecondViewController_iPhone" bundle:nil]; 
} else { 
    viewController1 = [[OrderPanelFirstViewController alloc] initWithNibName:@"OrderPanelFirstViewController_iPad" bundle:nil]; 
    viewController2 = [[OrderPanelSecondViewController alloc] initWithNibName:@"OrderPanelSecondViewController_iPad" bundle:nil]; 
} 
self.tabBarController = [[UITabBarController alloc] init]; 
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil]; 
self.window.rootViewController = self.tabBarController; 
[self.window makeKeyAndVisible]; 
return YES; 
} 

那麼,如何調用orderPanel在我當前視圖控制器類OrderPanel?

- (IBAction)T1pressed:(id)sender { 
     // how do i call order panel? 

} 
+0

你假設的東西,張貼你吃的細節something.Half而explaining.Please編輯上面的問題,並介紹你想要什麼...... –

+0

我想要在標籤視圖頂部的標籤視圖。 – VinsonG

+0

喜歡帶有2個選項卡的tab控制器< - 這很容易實現,因爲Xcode IDE幫助了我,但是如果我想在其中一箇舊選項卡中再次添加帶有2個選項卡的選項卡控制器。我該怎麼做? – VinsonG

回答

1

試試這個:

self.tabBarController = [[UITabBarController alloc] init]; 

UIViewController *viewController1 = [[firstViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 

tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1 ,viewController2, nil]; 

[self.view addSubview:tabBarController.view]; 
+0

viewControllers是什麼? – VinsonG

+0

@ user1933421標籤欄界面顯示的根視圖控制器數組。 – iAppDeveloper

+0

代碼不工作... – VinsonG

相關問題