我正在尝试将 destinationVC 的 currentVC 设置为 delegate ,该导航将通过 UITabBarController ,并嵌入到 UINavigationController 中。
我不能将当前的VC设置为委托,因为 prepareForSegue 永远不会触发,并且提供的其他解决方案也不起作用(底部代码)。
所有这些都通过 Interface-builder
设置为 Storyboards这是架构:
-> UITabBarController
-> UINavigationController
-> currentVC(将其设置为委托)
-> UINavigationController
-> destinationVC
这什么都不做:
override func prepare(for segue: uistoryboardSegue,sender: Any?) {
print ("The Segue was triggered")
let destinationVC = segue.destination as! MyViewController
destinationVC.delegate = self
}
我也无法使它正常工作(它永远不会通过IF语句):
override func viewDidLoad() {
super.viewDidLoad()
if let myDestinationVC = (self.tabBarController?.viewControllers![0] as? UINavigationController)?.viewControllers[0] as? destinationVC {
print ("The IF statement was triggered")
myDestinationVC.delegate = self
}
}
我有一个用于TabBarController的自定义类,该类现在实际上并没有执行任何操作-我不确定是否需要在上面的代码中引用它?