如何将数据从一个视图控制器传递到选项卡式视图控制器?

问题描述 投票:0回答:2

我有一个ViewController A和一个带有4个子ViewController B,C,D,E的标签栏控制器。

我想从VcA传递字符串数据-> VcB。因此,如何传递数据,请帮帮我。

在View Controller A中]

@IBAction func nextButonTapped(_ sender: Any) {
if let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Tabbar") as? ViewControllerB{


            vc.data = "Hello"

              }
}

在标签栏的viewcontrollerB中,我刚刚打印了var“ data”

我有一个ViewcontrollerA和一个带有4个子ViewController B,C,D,E的标签栏控制器。我想从VcA-> VcB传递字符串数据。因此,如何传递数据,请帮帮我。在视图中...

swift swift5
2个回答
1
投票

如果您在与VCB/TabBar相同的NavigationController上推动VCA,则可以从VCA内部的navigationController轻松访问VCB,如下所示]


0
投票

如果您正在使用NavigationController传递数据viewController-> Tabcontroller。请尝试在按钮/ tableviewCell / collectionViewCell上点击代码。单击/按下

© www.soinside.com 2019 - 2024. All rights reserved.