When you implement present ViewController like Modal, some of case you'd see "Attempt to present which is already presenting".
Before code
uiView.window?.rootViewController?.present(viewController, animated: true)
Error log
[Presentation] Attempt to present <UIViewController: 0x10c72d050> on <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x10c60ab30> (from <_TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier__: 0x10c60ab30>) which is already presenting <UIViewController: 0x1201f72b0>.
After code
guard let rootViewController =
uiView.window?.rootViewController else { return }
if rootViewController.presentedViewController == nil {
rootViewController.present(viewController, animated: true)
}
Top comments (0)