Skip to content

Instantly share code, notes, and snippets.

@sonsongithub
Created September 11, 2022 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonsongithub/0ee7194de04dee7420f0e814903c4ae4 to your computer and use it in GitHub Desktop.
Save sonsongithub/0ee7194de04dee7420f0e814903c4ae4 to your computer and use it in GitHub Desktop.
Prevents the window from being displayed for Mac Catalyst.
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