-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Description
I have here is such code
private func showNotification() {
if !Thread.isMainThread {
DispatchQueue.main.async { self.showNotification() }
return
}
guard let rootVC = UIApplication.topViewController() else {
print(">>> No root view controller defined")
return
}
Loaf("Importing ...", sender: rootVC).show()
}where function topViewController (extension of UIApplication) return top-level current view controller
static func topViewController(base: UIViewController? = UIApplication.shared.delegate?.window??.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return topViewController(base: nav.visibleViewController)
}
if let tab = base as? UITabBarController, let selected = tab.selectedViewController {
return topViewController(base: selected)
}
if let presented = base?.presentedViewController {
return topViewController(base: presented)
}
return base
}Here's the problem: if I call showNotification multiple times, then the Loaf is shown only once - the first time.
After the first Loaf has disappeared all subsequent calls to Loaf(...).show() lead to nothing
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels