How do you disable support for external displays when using UISceneDelegate?

Background:

We have an iOS app that supports a single window. We are using a UISceneDelegate. We do not support multiple windows or scenes.

Problem:

When a user mirrors the screen of their iPhone device, iOS automatically initializes a new scene with a non-interactive display role. For the time being, we would like to disable opting into this and instead simply mirror the existing device window.

Going through the docs, I haven't been able to find any way of doing this. All the docs appear to assume that once you start supporting UIScene, you should automatically support any screen size, aspect ratio or connected display.

In the Scenes Overview section, it claims that setting UIApplicationSupportsMultipleScenes to false will never create multiple windows, but I've confirmed under the debugger that this isn't true.

Any ideas?

Repro Steps:

  • Create an iOS app with a single window that supports UISceneDelegate
  • Launch the app on your iPhone (tested using iOS 17.3)
  • Turn on your Apple TV
  • From Control Center, tap the mirror icon (two small windows)

Replies

When a user mirrors the screen of their iPhone device, iOS automatically initializes a new scene with a non-interactive display role. For the time being, we would like to disable opting into this...

The receiving of a windowExternalDisplayNonInteractive scene is not something that can be blocked. If the system determines it wants to offer your application this scene it will always be offered.

and instead simply mirror the existing device window.

However, unlike other scenes provided to your app, this scene is special. You should only put something in this scene if you want to render content there. If you don't, or you change your mind, the system will mirror content into this scene. You express either by adding or removing your UIWindow to this scene.

In the Scenes Overview section, it claims that setting UIApplicationSupportsMultipleScenes to false will never create multiple windows, but I've confirmed under the debugger that this isn't true.

Again, windowExternalDisplayNonInteractive is a special case. Prior to scenes, external displays connected as additional UIScreen instances and had a similar behavior, so windowExternalDisplayNonInteractive was implemented to have similar semantics.

The TL;DR here is that you can ignore this scene and not add a UIWindow to it if you don't want to put anything there. Unlike windowApplication, it is completely optional. We could do a better job documenting all this. I filed something to improve that.

Thanks for the prompt response, it was very helpful. I was able to add checks in the UISceneDelegate and get the app to display properly, effectively giving us the behaviour we were hoping for.

Thanks!

Patrick