I have an app that will need to connect to an external display, and I want to display different content on both screens (not just mirror the iPad screen).
I have tried adding a Scene Configuration in my Info.plist
:
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
<dict>
<key>UISceneConfigurationName</key>
<string>External Screen</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).ExtSceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Ext</string>
</dict>
</array>
</dict>
</dict>
I also added a switch to return the correct UISceneConfiguration
for each screen.
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
switch connectingSceneSession.role.rawValue {
case "UIWindowSceneSessionRoleApplication":
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
case "UIWindowSceneSessionRoleExternalDisplay":
return UISceneConfiguration(name: "External Screen", sessionRole: connectingSceneSession.role)
default:
fatalError("No such role, I think? \(connectingSceneSession.role.rawValue)")
}
}
While the breakpoint I have set in the above code in configurationForConnecting
in my AppDelegate
is called when I connect the external screen, my app still simply mirrors the iPad screen.
I tried following this tutorial, but since iOS 13 the screen
setter is deprecated, and this code does not work.
I really don't know how I can display different content on different physical screens, could someone point me in the right direction?