Storyboard - Popping to a View Controller then Pushing Causes multiple pushes

205 views Asked by At

In Objective C / iOS;

We have a process similar to this (set up in xcode storyboard);

Menu View Controller -> Enter in a code -> Process/Validate -> Present a Failed Code page

The (->) arrows signify a push segue setup in storyboard

When in failed state I want to pop to the Enter in a code view controller.

 UIViewController *vc = nil;

    NSUInteger index=0;
    for (UIViewController *viewController in self.navigationController.viewControllers) {
        if ([viewController isKindOfClass:[SomeViewController class]]) {
            vc = viewController;
            break;
        }
        index++;
    }

    if (vc) {
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            [self.navigationController popToViewController:vc animated:YES];
        });
        return;
    }

This pops me back to the VC I want to go to.

Except now when I press a submit on the Enter code page it does 3 or 4 more "pushes", when it should only be 1.

Do I need to unwind the segue? I tried emptying the navigational view controller stack, and I even tried ridding it of its last active view controller -- both of these return a blank or black window view frame.

Why would popping a view controller in the navigation stack affect the segues in my view controller to the point where whenever I try to do a push segue action it will try to push multiple view controllers onto the stack?

1

There are 1 answers

0
Atilla Jax On BEST ANSWER

Turns out I had the following issue

Button press causes segue action in storyboard I did the same segue action in code on the button, hence pushing multiple times

I have now solved this issue