Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You might consider swapping view controllers <em>not</em> views, using UINavigationController.</p> <p>In your AppDelegate.h</p> <pre><code>@interface AppDelegate : NSObject &lt;UIApplicationDelegate&gt; { UIWindow *window; UINavigationController *navigationController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @end </code></pre> <p>And in -[AppDelegate applicationDidFinishLaunching:] instantiate navigationController, thus:</p> <pre><code>[self setNavigationController:[[UINavigationController alloc] initWithRootViewController:mySuperviewController]]; [[self navigationController] setNavigationBarHidden:YES]; // Configure and show the window [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; </code></pre> <p>Then within SuperviewController.m you can instantiate your MainMenuController and MainGameController, as you already do. To start with MainMenuController you could do this in SuperviewController -viewDidLoad</p> <pre><code>[[self navigationController] pushViewController:[self mainMenuController] animated:YES]; </code></pre> <p>You would need to add some smarts to switch directly between mainMenuController and mainGameController - but it wouldn't be difficult.</p> <p>So as not to reload nibs again and again, consider defining accessor methods like this:</p> <pre><code>- (MainGameController*) mainGameController { if (mainGameController == nil) { mainGameController = [[MainGameController alloc] initWithNibName:@"MainGame" bundle:nil]; } return mainGameController; } </code></pre> <p>Also, bear in mind that switching between sibling view controllers involve popping current view controller (e.g., mainMenuController) <em>before</em> pushing other view controller (e.g., mainGameController).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload