master
 1//
 2//  FirstViewController.m
 3//  MultiViewXIBNav
 4//
 5//  Created by mo khan on 2013-05-21.
 6//  Copyright (c) 2013 mo khan. All rights reserved.
 7//
 8
 9#import "FirstViewController.h"
10#import "SecondViewController.h"
11
12@interface FirstViewController ()
13
14@end
15
16@implementation FirstViewController
17
18- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
19{
20    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
21    if (self) {
22        self.title = @"First";
23    }
24    UIBarButtonItem * secondButton = [[UIBarButtonItem alloc] initWithTitle:@"Second" style:UIBarButtonItemStylePlain target:self action:@selector(gotoSecondView:)];
25    self.navigationItem.rightBarButtonItem = secondButton;
26    return self;
27}
28
29- (void)viewDidLoad
30{
31    [super viewDidLoad];
32    // Do any additional setup after loading the view from its nib.
33}
34
35- (void)didReceiveMemoryWarning
36{
37    [super didReceiveMemoryWarning];
38    // Dispose of any resources that can be recreated.
39}
40
41- (void) gotoSecondView:(id)sender
42{
43    NSLog(@"Second button works");
44    if (!self.mySecondVC)
45    {
46        self.mySecondVC = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
47    }
48    
49    [self.navigationController pushViewController:self.mySecondVC animated:YES];
50}
51
52@end