小编Dvi*_*act的帖子

在视图控制器之间传递数据使用从导航控制器中嵌入的视图到tabbarcontroller的segue

我有两个视图,我想将数据从一个视图传递到下一个视图.第一个视图是我有数据,我想传递给下一个视图让我们调用它SourceViewController.但是SourceViewController嵌入在a NavigationViewController和secondViewController让我们调用它DestinationViewController是一个中的firstView TabViewController.

我试图使用这个问题的答案,它无法通过导航视图,它只是跳过整个逻辑.

这是我的代码:

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "loginSuccessSugue") {

        if let tab = self.presentingViewController as? UITabBarController,
            let nav = tab.viewControllers?[0] as? UINavigationController,
            let destinationVC = nav.viewControllers.first as? HomeViewController {


             destinationVC.currentBalance = serviceBalance
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

这是HomeViewController:

class HomeViewController: UIViewController , UITableViewDelegate,UITableViewDataSource, UICircularProgressRingDelegate{

var currentBalance = 0.0

 override func viewDidLoad() {
    super.viewDidLoad()

    circularBalance.maxValue = CGFloat(currentBalance)
     print(currentBalance)

   }

  override func viewDidAppear(_ …
Run Code Online (Sandbox Code Playgroud)

storyboard segue uistoryboardsegue swift

5
推荐指数
1
解决办法
594
查看次数

标签 统计

segue ×1

storyboard ×1

swift ×1

uistoryboardsegue ×1