Protocol

UISceneDelegate

The core methods you use to respond to life-cycle events occurring within a scene.

Declaration

protocol UISceneDelegate

Overview

Use your UISceneDelegate object to manage life-cycle events in one instance of your app's user interface. This interface defines methods for responding to state transitions that affect the scene, including when the scene enters the foreground and becomes active, and when it enters the background. Use your delegate to provide appropriate behavior when these transitions occur. For example, finish critical tasks and quiet your app when it enters the background.

Do not create UISceneDelegate objects directly. Instead, specify the name of your custom delegate class as part of the configuration data for your scenes. You can specify this information in your app's Info.plist file, or in the UISceneConfiguration object you return from your app delegate's application(_:configurationForConnecting:options:) method. For more information about how to configure scenes, see XREF.

Topics

Connecting and Disconnecting the Scene

func scene(UIScene, willConnectTo: UISceneSession, options: UIScene.ConnectionOptions)

Tells the delegate about the addition of a scene to the app.

func sceneDidDisconnect(UIScene)

Tells the delegate that UIKit removed a scene from your app.

class UIScene.ConnectionOptions

A data object containing information about the reasons why UIKit created the scene.

Transitioning to the Foreground

func sceneWillEnterForeground(UIScene)

Tells the delegate that the scene is about to begin running in the foreground and become visible to the user.

func sceneDidBecomeActive(UIScene)

Tells the delegate that the scene became active and is now responding to user events.

Transitioning to the Background

func sceneWillResignActive(UIScene)

Tells the delegate that the scene is about to resign the active state and stop responding to user events.

func sceneDidEnterBackground(UIScene)

Tells the delegate that the scene is running in the background and is no longer onscreen.

Opening URLs

func scene(UIScene, openURLContexts: Set<UIOpenURLContext>)

Asks the delegate to open one or more URLs.

Continuing User Activities

func scene(UIScene, willContinueUserActivityWithType: String)

Tells the delegate that it is about to receive Handoff-related data.

func scene(UIScene, continue: NSUserActivity)

Tells the delegate to handle the specified Handoff-related activity.

func scene(UIScene, didFailToContinueUserActivityWithType: String, error: Error)

Tells the delegate that the activity could not be continued.

Saving the State of the Scene

func stateRestorationActivity(for: UIScene) -> NSUserActivity?

Returns a user activity object encapsulating the current state of the specified scene.

func scene(UIScene, didUpdate: NSUserActivity)

Tells the delegate that the specified activity object was updated.

See Also

Window Scenes

Supporting Multiple Windows on iPad

Use the UIScene lifecycle to support two side-by-side instances of your interface and learn how to create a new window with drag and drop.

protocol UIWindowSceneDelegate

Additional methods that you use to manage app-specific tasks occurring in a scene.

Beta
class UIWindowScene

A specific type of scene that manages one or more windows for your app.

Beta
class UIScene

An object that represents one instance of your app's user interface.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software