Created
September 11, 2022 23:50
-
-
Save sonsongithub/0ee7194de04dee7420f0e814903c4ae4 to your computer and use it in GitHub Desktop.
Prevents the window from being displayed for Mac Catalyst.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DummyViewController: UIViewController { | |
deinit { | |
print(#function) | |
} | |
required init?(coder: NSCoder) { | |
print(#function) | |
super.init(coder: coder) | |
} | |
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { | |
print(#function) | |
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) | |
} | |
override func viewDidAppear(_ animated: Bool) { | |
super.viewDidAppear(animated) | |
UIApplication.shared.connectedScenes.forEach { (scene) in | |
if let uiscene = scene as? UIWindowScene { | |
uiscene.windows.forEach { (window) in | |
if window.rootViewController == self { | |
UIApplication.shared.requestSceneSessionDestruction(uiscene.session, options: .none) { (error) in | |
print(error) | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment