Question

I'm using a storyboard and storyboard id's, I'm several controllers deep in the navigation stack.

  • Menu Controller
  • Selection Controller
  • Item Controller
  • Result Controller

I'm currently on the 'Result Controller' and I want go to the 'Item Controller', but reset / reload that controller, I would be passing in the same property values that it currently has. So in effect I would be going up two levels then push.

I just wondered whats the best way to achieve this?

I guess I could call pop a couple of times then push within my 'Result Controller' passing property values to the 'Item Controller'?

Hmm, I guess I would have keep the animation for the first pop then disable it for the two pushes.

Hope this makes sense.

Was it helpful?

Solution 2

 for (UIViewController *controller in [self.navigationController viewControllers])
        {
            if ([controller isKindOfClass:[YourViewCOntrollerName class]])
            {
                [self.navigationController popToViewController:controller animated:YES];

                break;
            }
        }

OTHER TIPS

Try this. Maybe it will help you.

NSArray *vList = [[self navigationController] viewControllers];
    UIViewController *view;
    for (int i=[vList count]-1; i>=0; --i) {
        view = [vList objectAtIndex:i];
        if ([view.nibName isEqualToString: @"ItemController"])
        {
            [self.navigationController popToViewController:view animated:YES];
            break;
        }
    }

Try this

[self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:2] animated:YES];

you can go back at any index you want

Pop to specific view controller( in this case ItemController) you can use below code

[self.navigationController popToViewController:ItemController animated:YES];

The way you try to make it is not really optimal, and could end up causing you problems. The clean way to do this would be to code a way to reset the "Item Controller" so you just have to do 1 pop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top