I display my view to external display using UIScene as follows by selecting an appropriate UISceneConfiguration:
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
// return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
// This is not necessary; however, I found it useful for debugging
switch connectingSceneSession.role {
case .windowApplication:
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
case .windowExternalDisplay:
return UISceneConfiguration(name: "External Screen", sessionRole: connectingSceneSession.role)
default:
fatalError("Unknown Configuration \(connectingSceneSession.role.rawValue)")
}
}
The above API is called automatically when external screen is connected/disconnected. My question is whether there is anyway or API that disables/enables external screen display at runtime (without user disconnecting the HDMI cable)?