したがって、いくつかのオプションがあります。タブビューがナビゲーションコントローラーであるとします。その場合、使用したい「実際の」viewControllerをすぐにプッシュする一時的なviewControllerを作成でき、「実際の」viewControllerには以下のメソッドが実装されています。後で、navigationControllers viewControllers配列をリセットすることにより、一時的なコントローラーを完全に取り除くことができます。
- (BOOL) hidesBottomBarWhenPushed { return YES; }
それがうまくいかない場合は、window.rootViewControllerを使用してゲームをプレイできます。起動時に、viewControllerを作成し、それをrootViewControllerにします。後でタブバーが必要になったときに、appDelegateにメッセージを返して、tabBarControllerを作成し、ビューを最初のviewControllerにします(そのまま!)。Xcodeタブバープロジェクトを使用して、簡単なデモアプリでこれを確認しました。これが私が使用したコードです:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
self.window.rootViewController = viewController1;
[self.window makeKeyAndVisible];
return YES;
}
- (void)switcher
{
[viewController1.view removeFromSuperview];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
}