Wednesday 8 June 2011

How to Use NavigationController with Appdelegete and ViewController.

#import < UIKit/UIKit.h >

@interface SampleAppDelegate : NSObject
{
UIWindow *window;
UINavigationController *navigationcontroller;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationcontroller;
@end


#import " SampleAppDelegate.h "
#import "MainScreenViewController.h"

@implementation SampleAppDelegate

@synthesize window,navigationcontroller;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[window makeKeyAndVisible];
MainScreenViewController *MVC = [[MainScreenViewController alloc]init];
navigationcontroller = [[UINavigationController alloc]initWithRootViewController:MVC];
[MVC release];
[window addSubview:[navigationcontroller view]];
return YES;
}
- (void)dealloc
{
[window release];
[super dealloc];
}
@end

#import < UIKit/UIKit.h >

@interface MainScreenViewController : UIViewController
{
}
@end

#import "MainScreenViewController.h"

@implementation MainScreenViewController

- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = @"Home";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];

- (void)viewDidUnload {
[super viewDidUnload];
}

- (void)dealloc {
[super dealloc];
}

@end

No comments:

Post a Comment