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