Adding multi-window support to an iPad app with UIWindowScene
UISceneSession and the design rules Apple set for iPadOS.
- Answers
- How do you add multi-window support to an iPad app?
- Topics
- apple · design · iOS · iPad · programming · tablet · work
- Full article on willem.com
- https://willem.com/en/2019-10-07_multi-window-support-in-your-ipad-app/
Summary
You adopt UIWindowScene with its UISceneSession abstraction, which sits between UIScreen and UIWindow. On launch, check for an existing UISceneSession and reconnect to it, so the interface state survives when iPadOS closes your app in the background.
Full text
Apple added multi-window support to iPadOS with UIWindowScene and UISceneSession, sitting between UIScreen and UIWindow in the UI structure. The design rules matter as much as the code: every window of your app must be of the same kind and must be able to do everything the app can do. Users may open extra windows when they find it useful, for example two months of an agenda side by side or a map at two scales, but the app must never require more than one window. Because iPadOS closes background apps to save memory and battery, check at launch whether a UISceneSession already exists and reconnect to it, so the interface state persists and the user never notices the interruption. In my own apps, adopting these concepts took relatively little effort, and the same structure prepares an app for running on macOS.