-3

タブ バーを含むビュー コントローラーを初期化する方法がわかりません。タブ バーに 2 つのビュー コントローラーがありますか?

current_view_controller、OrderPanel、firstViewController、SecondViewController があります。

firstViewController と SecondViewController は、OrderPanel 内のタブです。current_view_controller で OrderPanel を正しく初期化して呼び出すにはどうすればよいですか?

これは、View Controller にタブをセットアップするクラス OrderPanel です。

  #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;
}

現在のView ControllerでorderPanelを呼び出すにはどうすればよいですか?

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

}
4

1 に答える 1

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];
于 2013-01-25T10:43:57.237 に答える