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_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = 2P4CP47H76;
|
DEVELOPMENT_TEAM = 2P4CP47H76;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
@@ -296,7 +296,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Pocket Poster/Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = 2P4CP47H76;
|
DEVELOPMENT_TEAM = 2P4CP47H76;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import UIKit
|
|||||||
|
|
||||||
// credit: sourcelocation & TrollTools
|
// credit: sourcelocation & TrollTools
|
||||||
var currentUIAlertController: UIAlertController?
|
var currentUIAlertController: UIAlertController?
|
||||||
|
var lastDismissTitle: String?
|
||||||
|
|
||||||
|
|
||||||
fileprivate let errorString = NSLocalizedString("Error", comment: "")
|
fileprivate let errorString = NSLocalizedString("Error", comment: "")
|
||||||
@@ -19,6 +20,7 @@ extension UIApplication {
|
|||||||
|
|
||||||
func dismissAlert(animated: Bool) {
|
func dismissAlert(animated: Bool) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
lastDismissTitle = currentUIAlertController?.title
|
||||||
currentUIAlertController?.dismiss(animated: animated)
|
currentUIAlertController?.dismiss(animated: animated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,8 +62,8 @@ extension UIApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func present(alert: UIAlertController) {
|
func present(alert: UIAlertController) {
|
||||||
if var topController = self.windows[0].rootViewController {
|
if let window = UIApplication.shared.connectedScenes.map({ $0 as? UIWindowScene }).compactMap({ $0 }).first?.windows.first, var topController = window.rootViewController {
|
||||||
while let presentedViewController = topController.presentedViewController {
|
while let presentedViewController = topController.presentedViewController, presentedViewController.title != lastDismissTitle {
|
||||||
topController = presentedViewController
|
topController = presentedViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ struct ContentView: View {
|
|||||||
SymHandler.cleanup() // just to be extra sure
|
SymHandler.cleanup() // just to be extra sure
|
||||||
try? FileManager.default.removeItem(at: pbManager.getTendiesStoreURL())
|
try? FileManager.default.removeItem(at: pbManager.getTendiesStoreURL())
|
||||||
UIApplication.shared.dismissAlert(animated: false)
|
UIApplication.shared.dismissAlert(animated: false)
|
||||||
Haptic.shared.notify(.success)
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.35, execute: {
|
||||||
pbManager.selectedTendies.removeAll()
|
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: {
|
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() {
|
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: {
|
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