Structure

WindowGroup

A scene that presents a group of identically structured windows. あるシーン、それは全く同じに構造化されたウインドウそれらからなるあるグループを表します。

Declaration 宣言

struct WindowGroup<Content> where Content : View

Overview 概要

Use a WindowGroup as a container for a view hierarchy presented by your app. The hierarchy that you declare as the group’s content serves as a template for each window that the app creates from that group:


@main
struct Mail: App {
    var body: some Scene {
        WindowGroup {
            MailViewer() // Declare a view hierarchy here.
        }
    }
}

SwiftUI takes care of certain platform-specific behaviors. For example, on platforms that support it, like macOS and iPadOS, users can open more than one window from the group simultaneously. In macOS, users can gather open windows together in a tabbed interface. Also in macOS, window groups automatically provide commands for standard window management.

Every window created from the group maintains independent state. For example, for each new window created from the group the system allocates new storage for any State or StateObject variables instantiated by the scene’s view hierarchy.

You typically use a window group for the main interface of an app that isn’t document-based. For document-based apps, use a DocumentGroup instead.

Topics 話題

Creating a Window Group

Creating a Titled Window Group

Creating a Window Group with an Identifier

Creating a Titled Window Group with an Identifier

Supporting Types 支援を行う型

Default Implementations 省略時実装

Relationships 関係

Conforms To 次に準拠

See Also 参照

Primary Scenes