Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use multiple custom View Controllers with a Navigation Controller?
    text
    copied!<p>Basically, I have two view controllers inside the MainWindow.xib that can be viewed by clicking the Bar Button in my Navigation Controller. I wanted those two view controllers to be separated from the MainWindow.xib with their own header, implementation and xib files and still make Navigation Controller inside of MainWindow.xib work in them.</p> <p>To better understand it, please see the codes below:</p> <p>Thanks a lot!</p> <p><strong>TestAppDelegate.h</strong></p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface TestAppDelegate : NSObject &lt;UIApplicationDelegate&gt; { //Navigation Controller IBOutlet UINavigationController *navigationController; //View Controllers UIViewController *viewController; UIViewController *viewController2; UIViewController *viewController3; } @property (nonatomic, retain) IBOutlet UIWindow *window; //Navigation Controller @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; //View Controllers @property (nonatomic, retain) IBOutlet UIViewController *viewController; @property (nonatomic, retain) IBOutlet UIViewController *viewController2; @property (nonatomic, retain) IBOutlet UIViewController *viewController3; - (IBAction)next; - (IBAction)next2; @end </code></pre> <p><strong>TestAppDelegate.m</strong></p> <pre><code>#import "TestAppDelegate.h" @implementation TestAppDelegate @synthesize window = _window; //Navigation Controller @synthesize navigationController; //View Controllers @synthesize viewController; @synthesize viewController2; @synthesize viewController3; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. //Navigation Controller [self.window addSubview:[navigationController view]]; [self.window makeKeyAndVisible]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { } - (void)applicationDidEnterBackground:(UIApplication *)application { } - (void)applicationWillEnterForeground:(UIApplication *)application { } - (void)applicationDidBecomeActive:(UIApplication *)application { } - (void)applicationWillTerminate:(UIApplication *)application { } - (void)dealloc { [viewController release]; [viewController2 release]; [viewController3 release]; [navigationController release]; [_window release]; [super dealloc]; } - (IBAction)next { [navigationController pushViewController:viewController2 animated:YES]; } - (IBAction)next2 { [navigationController pushViewController:viewController3 animated:YES]; } @end </code></pre> <p><strong>Inside MainWindow.xib:</strong></p> <p><a href="http://i52.tinypic.com/10xa45f.png" rel="nofollow">http://i52.tinypic.com/10xa45f.png</a></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