Pregunta

I have the following setup:

  1. Tab one: a series of view controller to purchase an item placing it in a shopping cart.
  2. Tab two: a series of view controllers that show what you purchased in the past with a button to reorder. When you click reorder it places the items in the shopping cart

This is a simple graphical representation:

enter image description here

My problem is the following: Given that there are two paths to the shopping cart, it's possible to have two instances of it and that's very confusing to the user. How do I make sure the cart always loads in tab 1?

¿Fue útil?

Solución

Create yours custom segue: subclass UIStoryboardSegue and in -perofrm implement opening first tab and pushing SecondViewController.

- (void) perform
{
    SecondTabViewController* stvc = self.sourceViewController;
    UITabBarController* tbc = stvc.navigationController.tabBarController;
    UINavigationViewController* nvc = tbc.viewControllers.firstObject;
    tbc.selectedViewController = nvc;
    [nvc pushViewController:self.destinationViewController animated:YES];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top