1

I have some storyboards setup as below:

Storyboard A

--> Root Navigation Controller --> Container View Controller --> View Controller --> Home View Controller --> Storyboard B Reference

Storyboard B

--> Container View Controller --> Navigation Controller --> View Controller --> Storyboard C Reference

Storyboard C

--> Navigation Controller --> View Controller

The gist of it is, I load the app and the rootViewController is set. I then browse through the app and end up in Storyboard B which contains a button that takes me to Storyboard C. On the View Controller in Storyboard C there is a button that I want to take me back to the start of the app.

How, from the View Controller in Storyboard C, can I get back to the Home View Controller in Storyboard A?

Things I have tried:

[self.navigationController.navigationController popViewControllerAnimated:animated];

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"HomeScreen"];
[self presentViewController:viewController animated:animated completion:nil];

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"HomeScreen"];
[UIApplication sharedApplication].keyWindow.rootViewController = viewController;

The above 3 all go back to the right place but then the app crashes with EXC_I386_GPFLT.

I have also tried a few other things that didn't work. I know this is probably something very simple and i'm just having a bad day. Any suggestions are greatly appreciated right now.

Hodson
  • 3,438
  • 1
  • 23
  • 51
  • I would prefer first method, anyway try putting an exception breakpoint and check where its crashing, also post any crash log you get – Johnykutty Jan 12 '16 at 10:32
  • Adding an exception breakpoint was one of the first things I did but it offered no assistance. it just crashed in the main.m file. Also, I don't seem to be able to find anything in the logs. I will have to continue the hunt after lunch. – Hodson Jan 12 '16 at 10:54
  • if you add any view controllers view as a subview, make sure that you added it as child view controller too for more info http://stackoverflow.com/questions/25268744/exc-bad-access-exc-i386-gpflt-while-click-on-button – Johnykutty Jan 12 '16 at 10:58
  • I managed to find and add a couple of logs that appeared after the crash on my device. I will take a look into your last comment now. – Hodson Jan 12 '16 at 11:50

1 Answers1

1

I seem to have solved it by performing the popViewControllerAnimated: method on the main thread:

[self.navigationController.navigationController performSelectorOnMainThread:@selector(popViewControllerAnimated:) withObject:nil waitUntilDone:nil];
Hodson
  • 3,438
  • 1
  • 23
  • 51