Настройка многоэкранного приложения SwiftUI с использованием сценIOS

Программируем под IOS
Ответить
Anonymous
 Настройка многоэкранного приложения SwiftUI с использованием сцен

Сообщение Anonymous »


I am trying to set up a SwiftUI app that shows different UI on the device's app and the external, non-interactive display (like Keynote does when presenting).

What I have so far:
  • @main app structure with @UIApplicationDelegateAdaptor(AppDelegate.self)
  • InternalDisplayView and ExternalDisplayView. If possible I would like the latter to only show up on an external display (and not for example in another window on an iPad).
  • I have noticed that observing UIScreen.didConnectNotification works, but it's deprecated and I suppose will be removed since Xcode 16, hence I want to use UIAppDelegate and UIWindowSceneDelegate.

I have tried both setting up the info.plist with two different scene types and setting up none, set Enable Multiple Windows to both YES and NO.

In AppDelegate I have:

func application( _ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions ) -> UISceneConfiguration { let config: UISceneConfiguration = if connectingSceneSession.configuration.role == .windowExternalDisplayNonInteractive { .init(name: "External", sessionRole: .windowExternalDisplayNonInteractive) } else { .init(name: "Default", sessionRole: connectingSceneSession.role) } config.delegateClass = SceneDelegate.self // my custom SceneDelegate return config } But when connecting an external display the .windowExternalDisplayNonInteractive role is not set. In fact, this AppDelegate function does not get called when display connects at all.

What am I doing incorrectly in this setup?


Источник: https://stackoverflow.com/questions/781 ... ing-scenes
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»