mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-21 08:11:40 +02:00
Add iPadOS Scenes
This commit is contained in:
27
Examples/iPadOS Scenes/BehindTheScenes/SwiftUISceneDelegate.swift
Executable file
27
Examples/iPadOS Scenes/BehindTheScenes/SwiftUISceneDelegate.swift
Executable file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// SwiftUISceneDelegate.swift
|
||||
// BehindTheScenes
|
||||
//
|
||||
// Created by Simeon Saint-Saens on 4/6/19.
|
||||
// Copyright © 2019 Two Lives Left. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class SwiftUISceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
guard let windowScene = (scene as? UIWindowScene) else { return }
|
||||
|
||||
let count = session.userInfo?["SceneCount"] as? Int ?? 0
|
||||
|
||||
window = UIWindow(windowScene: windowScene)
|
||||
window?.rootViewController = UIHostingController(rootView: ContentView(count: count))
|
||||
window?.makeKeyAndVisible()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user