Skip to content

Commit 735b367

Browse files
fix: 점검페이지 present 로직 개선
이미 present 중인 viewcontroller가 있는 경우, dismiss 후 present 합니다.
1 parent e6e9d2f commit 735b367

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

Koin/Apps/SceneDelegate.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ import UIKit
1010
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1111

1212
var window: UIWindow?
13-
var urlParameters: [String: String]?
13+
private var isPresentingPresentErrorViewController = false
1414

1515
override init() {
1616
super.init()
1717
NotificationCenter.default.addObserver(self, selector: #selector(presentErrorViewController), name: NSNotification.Name("ServerError"), object: nil)
1818
}
1919

20+
deinit {
21+
NotificationCenter.default.removeObserver(self)
22+
}
23+
2024
func scene(_ scene: UIScene,
2125
willConnectTo session: UISceneSession,
2226
options connectionOptions: UIScene.ConnectionOptions) {
@@ -122,16 +126,29 @@ extension SceneDelegate {
122126

123127
@objc private func presentErrorViewController() {
124128

129+
guard isPresentingPresentErrorViewController == false else {
130+
return
131+
}
132+
isPresentingPresentErrorViewController = true
133+
125134
if let navigationController = window?.rootViewController as? UINavigationController {
126135

127136
let homeViewController = makeHomeViewController()
128-
let completion: ()->Void = {
137+
let completion: ()->Void = { [weak self] in
138+
self?.isPresentingPresentErrorViewController = false
129139
navigationController.setViewControllers([homeViewController], animated: false)
130140
}
131141
let errorViewController = ErrorViewController(completion: completion).then {
132142
$0.modalPresentationStyle = .fullScreen
133143
}
134-
navigationController.present(errorViewController, animated: true)
144+
145+
if let _ = navigationController.presentedViewController {
146+
navigationController.dismiss(animated: true) {
147+
navigationController.present(errorViewController, animated: true)
148+
}
149+
} else {
150+
navigationController.present(errorViewController, animated: true)
151+
}
135152
}
136153
}
137154
}

0 commit comments

Comments
 (0)