- iOS 13.0+
- Xcode 11.4+
This sample shows how to create multiple windows that give users the ability to create separate parts of your application with similar or varying content. Windows are managed by a scene or
UIScene class. Your application uses
When you adopt a multi-window architecture, the
UIApplication class that manages your application now manages newly created scenes. Then,
UIScene replaces the code in the delegate functions of
UIKit provides a subclass of
UIWindow designed specifically to help manage your windows. When adopting the multi-window architecture in an existing application running on iOS 12 or earlier, you will move more responsibility from
For more information on multiple windows in an iPadOS app, refer to Human Interface Guidelines for iOS.
Add Multiple Scene Support
To support multiple windows, the app’s
Info requires a manifest or UIApplicationSceneManifest, which contains the information about the app’s scene-based life-cycle support. The presence of this key indicates that the app supports scenes and does not use an app delegate object to manage transitions to and from the foreground or background. Include the key
UIApplication, with its boolean value set to true, which indicates that the app support two or more scenes simultaneously.
Add a Scene Delegate
This sample provides a
UIWindow subclass called
Scene to manage the app’s primary window scene. The
scene(_: delegate function sets up the window and content.
By using UISceneConfigurations key in the
Info scene manifest, the sample’s window for this scene is automatically configured and its root view controller is loaded from the storyboard.
Restore a Scene
When it’s time to restore a scene, iOS will call your delegate
scene(_:. The sample app restores the scene to its previous state through the use of
Create Multiple Windows
This sample creates a separate window only when the user drags an image from the collection view to the left or right side of the iPad screen. The sample creates a new window by implementing
collection and providing a
UIDrag with an associated
NSItem. Then, the sample passes the photo data to the new window scene with a registered