
我试图使用this question的答案,它无法通过导航视图,它只是跳过整个逻辑.
这是我的代码:
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 } }} 这是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(_ animated: Bool) { print(currentBalance) circularBalance.setProgress(value: CGfloat(currentBalance),animationDuration: 3) }} 这就是故事板的样子:
@H_502_4@解决方法 这是我的视图控制器,您可以在其中检查我是否向tabbar第一个vIEwcontroller发送5:class VIEwController: UIVIEwController { overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. self.performSegue(withIDentifIEr: "segueIDentifIEr",sender: self) } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } // MARK: - Navigation // In a storyboard-based application,you will often want to do a little preparation before navigation overrIDe func prepare(for segue: UIStoryboardSegue,sender: Any?) { let barVIEwControllers = segue.destination as! UITabbarController let destinationNv = barVIEwControllers.vIEwControllers?[0] as! UINavigationController let destinationVIEwController = destinationNv.vIEwControllers[0] as! FirstVIEwController destinationVIEwController.currentBalance = 5 }} 现在您可以查看我的第一个视图控制器,您可以在哪里检查我们获得的值.
class FirstVIEwController: UIVIEwController { var currentBalance = 0 overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw. print(currentBalance) } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. }} 现在,您可以查看我的控制台和故事板:
以上是内存溢出为你收集整理的swift – 在视图控制器之间传递数据使用从导航控制器中嵌入的视图到tabbarcontroller的segue全部内容,希望文章能够帮你解决swift – 在视图控制器之间传递数据使用从导航控制器中嵌入的视图到tabbarcontroller的segue所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)