I have a navigation based view controller (root?) where I created (programatically) a home button that takes the user to the main menu.
This main menu is a simple view controller and not part of the navigation controller.
To connect the two I have used the following code:
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainMenu"];
[self.navigationController pushViewController:vc animated:YES];
Despite working, it just pushes the view controller on the stack with the navigation bar.
What I am trying to do is dismiss the navigation controller and return to the start.
I tried using the following code:
ViewController *viewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[self presentModalViewController:viewController animated:YES];
However I get the following crash: reason: 'Could not load NIB in bundle: 'NSBundle
My question is how can I open another view controller programatically and dismiss the navigation controller? I cannot see the button so segues are not possible.
Thank you in advanced
Try this line:
ViewController *viewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:[NSBundle mainBundle]];
in place of:
ViewController *viewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];