Contents

UISceneClosureConfirmation

A configuration specifying a confirmation dialog that will be shown before a user action will result in destruction of the scene session and the disconnection of the scene.

Declaration

@MainActor class UISceneClosureConfirmation

Overview

By default, the confirmation dialog includes a “Close” button (which closes the scene) and a “Cancel” button (which keeps the scene open). You can replace either of these default buttons by providing custom actions. Use a UIAlertAction with style .destructive to replace the “Close” button, or style .cancel to replace the “Cancel” button.

Example:

A property of this type is found on UIWindowScene. A scene setting its closureConfirmation may look something like

let closeAction = UIAlertAction(title:"End meeting for all", style:.destructive, handler: nil)
let cancelAction = UIAlertAction(title:"Stay in meeting", style:.cancel, handler:nil)
let myAction = UIAlertAction(title:"Leave & Assign new host", style:.default) { action in
   // work to do before the window closes
}
var closureConfirmation: UISceneClosureConfirmation =
   UISceneClosureConfirmation(title:"Leave or End meeting?",
                              message:"You are the host. Would you like to end the meeting for all participants?",
                              actions:[closeAction, cancelAction, myAction])

windowScene.closureConfirmation = closureConfirmation

With this property set, upon user initiated close, the system will present the closure confirmation dialog.

Topics

Initializers