I have 2 UIViewController
s and want to have UINavigationController with UINavigationBar & UINavigationItem on them. But my code doesn't working ..
here is my code :
#import "testView1.h"
#import "testView2.h"
@interface testView1 ()
@end
@implementation testView1
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor darkGrayColor];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self];
testView2 *detail = [testView2 new];
[navController pushViewController:detail animated:YES];
}
Try to embed navigation controller in storyboard as below :
First select your testView1
in storyboard .
Select Navigation Controller
And Changes as below
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
/// testView2 *detail = [testView2 new];
testView2 *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"testView2 Identifier"]; // if you have add controller in storyboard
[self.navigationController pushViewController:detail animated:YES];
}