Monday, November 19, 2012

Simple NavigationController one Xib to another Xib for iOS 6.0 Simulator






AppDelegate.h

#import <UIKit/UIKit.h>

@class ViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UIWindow *window;
ViewController *viewController;
UINavigationController *navi;
}

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) ViewController *viewController;

@end



AppDelegate.m

#import "AppDelegate.h"

#import "ViewController.h"

@implementation AppDelegate

@synthesize window,viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
navi=[[UINavigationController alloc]initWithRootViewController:viewController];
[navi setNavigationBarHidden:YES animated:YES];

[window addSubview:navi.view];
[self.window makeKeyAndVisible];
return YES;
}




ViewController.m

#import "ViewController.h"
#import "TableViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize btn;


- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

-(IBAction)btn_Clicked:(id)sender
{
NSLog(@"clicked");
TableViewController *nextView=[[TableViewController alloc]init]; // Which xib want to push
[self.navigationController pushViewController:nextView animated:YES];
}

No comments:

Post a Comment