SourceViewController
。然而,SourceViewController
嵌入在一个NavigationViewController
中,第二个视图控制器,我们称之为DestinationViewController
,是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
}
}
}
这是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)
}
}
这是故事板的样子:
![enter image description here](https://istack.dev59.com/UpqVE.webp)
destinationVC.currentBalance = serviceBalance
行上设置一个断点,看看这一行是否被执行。 - nayem