2012-04-26 9 views
0

私は画面の下部にタブバーがあるようにしようとしていますが、常にそこにあります。また、タブの1つでいくつかのメニューをクリックすると、戻ってくるオプション、つまりナビゲーションコントローラとタブバーコントローラが表示されます。タブバーコントローラ付きナビゲーションコントローラーの使用

私はまだiOSを理解していないので、私が見つけた答えは私を混乱させています。

この回答:Having a UITabBar AND a UINavigationController in an app?

それでは、どのように私はこれを実装していますか?私はApp Delegateでこのメソッドを変更すると思います。

- (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 = [[CFSDFirstViewController alloc] initWithNibName:@"CFSDFirstViewController_iPhone" bundle:nil]; 
     viewController2 = [[CFSDSecondViewController alloc] initWithNibName:@"CFSDSecondViewController_iPhone" bundle:nil]; 
    } else { 
     viewController1 = [[CFSDFirstViewController alloc] initWithNibName:@"CFSDFirstViewController_iPad" bundle:nil]; 
     viewController2 = [[CFSDSecondViewController alloc] initWithNibName:@"CFSDSecondViewController_iPad" bundle:nil]; 
    } 
    self.tabBarController = [[UITabBarController alloc] init]; 
    [self.tabBarController setDelegate:self]; 
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil]; 
    self.window.rootViewController = self.tabBarController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

ありがとうございました!

答えて

2

まず、ペン先名を手動で設定する必要はありません。あなたはそれらをCFSDFirstViewController~iphone.xibCFSDFirstViewController~ipad.xibという名前にすることができます。その後、[[CFSDFirstViewController alloc] init]に電話して、iOSに残りのことをさせることができます。情報については、iOS Supports Device-Specific Resourcesを参照してください。

あなたの質問についてはUINavigationControllerUITabBarControllerにのみ挿入できます。

CFSDFirstViewController viewController1 = [[CFSDFirstViewController alloc] init]; 
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:viewController1]; 

をして、私は手で書いたので、コードをチェックしてくださいfolliwing

self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController, nil]; 

ようnavControllerの代わりviewController1を使用します。それは次のようにUINavigationControllerviewController1をラップすることができません。また、ARC以外のプロジェクトを使用する場合は、メモリに注意を払う必要があります。

希望します。

関連する問題