简体   繁体   English

在另一个选项卡中执行搜索

[英]Perform a segue in another tab

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: 这是一个简单的图形表示:

在此处输入图片说明

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? 如何确定购物车始终在选项卡1中加载?

Create yours custom segue: subclass UIStoryboardSegue and in -perofrm implement opening first tab and pushing SecondViewController. 创建您的自定义segue: UIStoryboardSegue子类并在-perofrm实现打开第一个选项卡并按下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];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM