fix alert not finding right view controller
This commit is contained in:
1 parent
a1ce92f3eb
commit
a9cfe59c49
3 files changed
+7
-5
No files matched your search
@@ -264,7 +264,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = 2P4CP47H76;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
@@ -296,7 +296,7 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = 2P4CP47H76;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
||||
@@ -9,6 +9,7 @@ import UIKit
|
||||
|
||||
// credit: sourcelocation & TrollTools
|
||||
var currentUIAlertController: UIAlertController?
|
||||
var lastDismissTitle: String?
|
||||
|
||||
|
||||
fileprivate let errorString = NSLocalizedString("Error", comment: "")
|
||||
@@ -19,6 +20,7 @@ extension UIApplication {
|
||||
|
||||
func dismissAlert(animated: Bool) {
|
||||
DispatchQueue.main.async {
|
||||
lastDismissTitle = currentUIAlertController?.title
|
||||
currentUIAlertController?.dismiss(animated: animated)
|
||||
}
|
||||
}
|
||||
@@ -60,8 +62,8 @@ extension UIApplication {
|
||||
}
|
||||
|
||||
func present(alert: UIAlertController) {
|
||||
if var topController = self.windows[0].rootViewController {
|
||||
while let presentedViewController = topController.presentedViewController {
|
||||
if let window = UIApplication.shared.connectedScenes.map({ $0 as? UIWindowScene }).compactMap({ $0 }).first?.windows.first, var topController = window.rootViewController {
|
||||
while let presentedViewController = topController.presentedViewController, presentedViewController.title != lastDismissTitle {
|
||||
topController = presentedViewController
|
||||
}
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ struct ContentView: View {
|
||||
SymHandler.cleanup() // just to be extra sure
|
||||
try? FileManager.default.removeItem(at: pbManager.getTendiesStoreURL())
|
||||
UIApplication.shared.dismissAlert(animated: false)
|
||||
Haptic.shared.notify(.success)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: {
|
||||
pbManager.selectedTendies.removeAll()
|
||||
Haptic.shared.notify(.success)
|
||||
UIApplication.shared.confirmAlert(title: NSLocalizedString("Success!", comment: ""), body: NSLocalizedString("The PosterBoard app will now open. Please close it from the app switcher.", comment: ""), onOK: {
|
||||
if !pbManager.openPosterBoard() {
|
||||
UIApplication.shared.confirmAlert(title: NSLocalizedString("Falling Back to Shortcut", comment: ""), body: NSLocalizedString("PosterBoard failed to open directly. The fallback shortcut will now be opened.", comment: ""), onOK: {
|
||||
|
||||
Reference in new issue
Block a user