0
votes

This seems like such a stupid problem, but I can't seem to sort it out.

My user clicks on an icon located on the app's home screen, and the icon executes a modal segue, opening a view. From here, a user is able to click another button, which pushes them to a detail view. Here's the kicker: Once my user is on the detail view, and attempts to click another button, I get the error:

"Unbalanced calls to begin/end appearance transitions."

I'm assuming it's due to the amount of segues layering overtop of the original modal. In short, the process is: Modal, Push, Push. On that third push, the above "error" appears in the console.

How can I fix this? Here's the segue/code that the error occurs on:

.m

- (IBAction)purchasebuttonpressed:(id)sender
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_1" bundle:nil];
    StrainDetailViewController *yourViewController = (StrainDetailViewController *)[storyboard instantiateViewControllerWithIdentifier:@"DispensaryViewController"];

    [self.navigationController pushViewController:yourViewController animated:YES];



}
1
Do you also have a segue attached to the button whose action method is purchasebuttonpressed:? You're calling it a segue, but then you do a manual push. - rdelmar
Sorry, not a segue. Just a push. This code exists for my XIB file (it's a DetailView). The button is "pushing" to a view on my StoryBoard. - Brittany L
Where in the controller hierarchy is the navigation controller? - rdelmar
The Navigation Controller is attached to the main screen (homeviewcontroller). Hierarchy is: NavigationController > HomeViewController (push) > ViewController (modal) > TableViewController (push) > DetailViewController (Button Lives Here, and pushing it causes that message in the console). - Brittany L
I'm a little unsure of your structure, but I think the problem is where your navigation controller is. When you present the modal view controller, I think you should present a navigation controller instead, with ViewController as its root view controller. - rdelmar

1 Answers

1
votes

If I understand your app structure, and what you're trying to do, I think you need to change the arrangement of controllers to this:

HomeViewController (the window's root view controller)
     |
     | modal segue to:
     |
NavigationController whose root view controller is ViewController
     |
     | push to :
     |
TableViewController
     |
     | push to:
     |
DetailViewController

Another way to do this, and the way I prefer if the HomeViewController is like a startup screen or welcome screen -- something that you don't need to come back to after first seeing it, is to make the navigation controller the window's root view controller. In the navigation controller's root view controller (ViewController in your case), present the HomeViewController modally from the viewDidAppear method with no animation, so it will be the first thing the user sees. When the user wants to move on, dismiss HomeViewController, and you'll be in ViewController, and the HomeViewController will be deallocated. You'll need to put logic in that viewDidAppear method, so that the presentation of HomeViewController only happens the first time viewDidAppear is called.