2012-01-17 18 views
2

スプリットビューを使用してアプリケーションを作成する必要がありますが、スプリットのマスター側にタブバーを追加する必要があります。このフォーラムではいくつかのものを読んだことがありますが、右。 スプリットビューを使用すると、マスターと詳細の2つのビューコントローラーが実際に処理されることが理解できます。マスター側でタブバーが必要な場合は、appDelegateからマスターを呼び出す必要があります。私はタブバーのコントローラーとして設定することができますが、私は完全な誤解を持っているか、あるいは間違って実装しています。UITabBar in Master View

ここで私はappDelegateでやっていることがわかります。テンプレートに付属しているマスターVC以外のVCをロードしているのがわかります。私の最初の質問は、VCをロードするか、タブバープロトコル?:

WTDInitialViewController *initialViewController = [[WTDInitialViewController alloc] initWithNibName:@"WTDInitialViewController" bundle:nil]; 
    UINavigationController *initialNavigationController = [[UINavigationController alloc] initWithRootViewController:initialViewController]; 

    WTDDetailViewController *detailViewController = [[WTDDetailViewController alloc] initWithNibName:@"WTDDetailViewController_iPad" bundle:nil]; 
    UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; 

    self.splitViewController = [[UISplitViewController alloc] init]; 
    self.splitViewController.delegate = detailViewController; 
    self.splitViewController.viewControllers = [NSArray arrayWithObjects:initialNavigationController, detailNavigationController, nil]; 

    self.window.rootViewController = self.splitViewController; 

、これは私はいわゆるVC

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    // Custom initialization 
    NSMutableArray *vcArray = [[NSMutableArray alloc] initWithCapacity:1]; 
    _tabBarController = [[UITabBarController alloc] init]; 
    WTDMasterViewController *masterViewController = [[WTDMasterViewController alloc] initWithNibName:@"WTDMasterViewController_iPad" bundle:nil]; 
    _navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; 
    _navigationController.navigationBar.barStyle = UIBarStyleBlack; 
    [vcArray addObject:_navigationController]; 

    _tabBarController.viewControllers = vcArray; 
    _tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack; 
    self.tabBarController.selectedIndex = 0; 
    [_window addSubview:_tabBarController.view]; 
    [_window makeKeyAndVisible]; 
} 
return self; 

にそれは愚かな質問かもしれないが、私はそう行き止まりにヒットし、任意の助けがどうなるかであります大いに感謝します

答えて

0

まず、私はあなたがipadのSplitViewを作成していると仮定しています。それはMasterViewControllerとDetailViewControllerで始まります。また、MasterViewControllerはUITableviewベースです。代わりにTabbarベースを実装したい場合は、MasterViewControllerのViewWillAppearでこれを呼び出してください。

UIViewController *viewController1 = [[[YourTabView1 alloc] initWithNibName:@"YourTabView1" bundle:nil]autorelease]; 
//If you want the view support Navigation then do this 
UINavigationController *tab1 = [[[UINavigationController alloc] initWithRootViewController:viewController1]autorelease]; 

UIViewController *viewController2 = [[[YourTabView2 alloc] initWithNibName:@"YourTabView2" bundle:nil]autorelease]; 
UINavigationController *tab2 = [[[UINavigationController alloc] initWithRootViewController:viewController2]autorelease]; 

UITabBarController *tabbarController = [[UITabBarController alloc] init]; 
tabbarController.viewControllers = [NSArray arrayWithObjects:tab1,tab2,nil]; 

[self presentModalViewController:tabbarController animated:YES]; 

私はこれがうまくいくと思いますが(私はコードをテストしませんでした)。