仅SWIFTUI
我正在使用UIHostingController
,当我从父级撤消rootViewController
时我想处理
MAINVIEW
** [父母]
let alertHostingController = UIHostingController(rootView: SettingsView())
alertHostingController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
UIApplication.shared.windows[0].rootViewController?.present(alertHostingController, animated: false)
SETTINGS VIEW
** [孩子]
UIApplication.shared.windows[0].rootViewController?.dismiss(animated: true, completion: nil)
我想知道孩子何时被父母解雇...
有什么想法吗?
Ps。我想使用完成参数,但是我不知道如何阅读它
protocol ChildDelegate: class {
func childWasDismissed()
}
class ChildController: UIViewController {
var delegate: ChildDelegate?
deinit {
delegate?.childWasDismissed()
}
}
类似的东西。或与闭包相同。