正如您在所附图片中看到的,我有一个名为“Notifications”的根导航 Controller 和一个名为“NotificationsController”的 UIViewController。
所以我的问题是如何使用协议(protocol)和委托(delegate)将变量从NotificationsController传递回通知,因为在这种情况下没有segue,但它们之间有默认关系。
我的问题是否正确,或者是否有其他方法可以满足我的需要。
非常感谢任何帮助
最佳答案
从 View Controller 引用导航 Controller (它是可选的,因此您需要处理它):
// self is a UIViewController
self.navigationController
从导航 Controller 引用 View Controller :
// self is a UINavigationController
let index = // Index of the view controller. You may need to iterate over viewControllers to find this.
self.viewControllers[index]
关于ios - 如何使用 Swift 中的协议(protocol)和委托(delegate)将变量从 UIViewController 传递回根导航 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34771461/