【问题标题】:How to pass data and segue to a view controller embedded in a navigation controller in a different tab in Swift?如何将数据和 segue 传递给嵌入在 Swift 不同选项卡中的导航控制器中的视图控制器?
【发布时间】:2019-05-02 08:33:44
【问题描述】:

当用户按下按钮ViewController1 时,我想转至ViewController2 并将数据传递给它。在我尝试过的所有方法中,NavigationController 消失或TabBar 消失,这是我不想要的。有没有更好的方法将用户从ViewController1 带到ViewController2?。

【问题讨论】:

  • 您可以转到单击按钮上的特定选项卡,然后您需要执行 segue 转到ViewController2
  • @wings 所以我必须以编程方式更改 tabBarController.selectedIndex = 1 ,然后将代码添加到 rootViewController 的 viewDidAppear() 以连接到 View Controller 2?
  • 是的,你可以试试这个
  • @wings 但是如何在这种方法中将数据从 ViewContoller1 传递到 ViewController2?
  • 你需要把你的数据带到VC1 -> tabBar -> VC2 但我不确定它是否正确

标签: ios swift uiviewcontroller uinavigationcontroller segue


【解决方案1】:

TabBarControllerViewController1 之间插入一个 NavigationViewController。然后执行从 viewController1viewController2 的 segue 并使用 prepare 函数传递数据

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多