Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-17-2010, 01:24 AM   #4 (permalink)
Brix
Registered Member
 
Join Date: Sep 2009
Posts: 149
Brix is on a distinguished road
Default

Here's how I do it. From the start.

1.Create a new project, choose a Window-based Application. For example I named my project as Test.
//You will then have only two files, your TestAppDelegate.h and .m.

2.On your .h, create an "IBOutlet UINavigationController" like this:
Code:
#import <UIKit/UIKit.h>

@interface TestAppDelegate : NSObject <UIApplicationDelegate>
{
    UIWindow *window;
    IBOutlet UINavigationController *xNavi;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *xNavi;
@end
3.On your .m, synthesize and release the UINavigationController.
Code:
#import "TestAppDelegate.h"

@implementation TestAppDelegate
@synthesize window;
@synthesize xNavi;

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
    [window makeKeyAndVisible];
}

- (void)dealloc
{
	[xNavi release];
    [window release];
    [super dealloc];
}
@end
***Very Important: Always save the changes you make. Like for this, you may not be able to link your UINavigationController to your AppDelegate if you didn't save the changes above before moving to the next step.

4.Now, open your MainWindow.xib, Open Tools->Library. Or simply press command+shift+L.

5.From the library, drag a Navigation Controller to your MainWindow.xib. It should be together with your File's Owner, First Responder, Test App Delegate and Window.

6.Select your newly added UINavigation Controller and Open Tools->Connection Inspecter (command+2).

7.Connect Your Referncing Outlets to Test App Delegate. The xNavi should appear there, select it.

8.Save everything and try to run it.

9.If you see a white screen, that is because we are still seeing the window. What we need to do is to add xNavi to window, like this:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
	[window addSubview:self.xNavi.view];
    [window makeKeyAndVisible];
}
10.Try running it now. The only thing left is to place a View on the View controller of your Navigation Controller.

11.This is how I do it so that it would not be a tableView Controller.

12.Add a new file on your classes.

13.Select "UIViewController subclass".

14.Check on "With XIB for user interface".

15.Click next, then name it whatever you like, then Finish.

16.You will now have 5 files under your classes, appdelegate.m and .h, the three new files .m, .h and it's .xib.

17.Open your MainWindow.xib, expand your Navigation Controller, (Change your View Mode into List so you can expand the Controller).

18.When you expand the Navigation Controller, you should be able to see the Navigation Bar and View Controller (Root View Controller).

19.Select the View Controller then press command+4.

20.On the Class, select the Drop-Down box and locate your View Controller, the one you created earlier. Save and Close your MainWindow.xib.

21.To test that your View Controller is now connected to your Navigation Controller, go to your View Controller .m. On it's viewDidLoad() make something like this:
Code:
- (void)viewDidLoad
{
    [super viewDidLoad];
	self.view.backgroundColor = [UIColor brownColor]; 
}
22.Run the program, you should now see a brown screen
__________________
Praise be to God

Last edited by Brix; 02-17-2010 at 08:59 PM.
Brix is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,485
Threads: 94,041
Posts: 402,628
Top Poster: BrianSlick (7,978)
Welcome to our newest member, jianjue
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:52 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.