我关闭rootViewController [SwiftUI]时的句柄

问题描述 投票:0回答:1

我使用的是alertHosting,当我从父级撤消rootViewController时我想处理

MAINVIEW ** [父母]

let alertHostingController = UIHostingController(rootView: SettingsView())
                                alertHostingController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
                                UIApplication.shared.windows[0].rootViewController?.present(alertHostingController, animated: false)

SETTINGS VIEW ** [Child]

 UIApplication.shared.windows[0].rootViewController?.dismiss(animated: true, completion: nil)

我想知道孩子何时被父母解雇...

有什么想法吗?

swift swiftui dismiss
1个回答
0
投票
protocol ChildDelegate: class { func childWasDismissed() } class ChildController: UIViewController { var delegate: ChildDelegate? deinit { delegate?.childWasDismissed() } }
类似的东西。或与闭包相同。
© www.soinside.com 2019 - 2024. All rights reserved.