I have two view controllers connected to one another via segues. When someone presses a button, they transition to viewcontroller2. In that viewdidload, I then initiate them back to the original view controller by initiating the segue “backs” with this code:
[self performSegueWithIdentifier: @"backs" sender: self];
However, it keeps refusing this simple transition, saying that my view controller is out of the hierarchy? There are only two view controllers, so what I’m wondering is how that is even possible?
viewDidLoadis too soon. The view has loaded, but it has not been placed in the view hierarchy yet. You want to wait untilviewDidAppear. That is the first moment when the view controller’s view is actually part of the full view hierarchy. (Even then you might have to use delayed performance; I’m not sure.)Another issue about what you’re saying is that if you go from view controller A to view controller B by segue, you cannot go back by a normal segue. You have to use the new “unwind” segue feature, or else go back manually (e.g. dismiss a presented controller, pop a pushed controller).