How to control which view is shown when your app launches
About 2 min
How to control which view is shown when your app launches 관련
SwiftUI by Example
Back to Home
How to control which view is shown when your app launches | SwiftUI by Example
How to control which view is shown when your app launches
Updated for Xcode 15
When you make a new SwiftUI project, Xcode will automatically create a new Swift file with the same name as your project, which will be used to bootstrap your app – to present your initial user interface.
For example, the default file will look like this:
struct SwiftUITestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
So, you can just change ContentView
to whatever other view you want to show.
However, this is a great place to set up all the core UI you need, such as a tab view:
WindowGroup {
TabView {
HomeView()
ContactsView()
LocationView()
AccountView()
}
}
Similar solutions…
How to control which NavigationSplitView column is shown in compact layouts | SwiftUI by Example
How to control which NavigationSplitView column is shown in compact layouts
How to run code when your app launches | SwiftUI by Example
How to run code when your app launches
How to run an asynchronous task when a view is shown | SwiftUI by Example
How to run an asynchronous task when a view is shown
How to find which data change is causing a SwiftUI view to update | SwiftUI by Example
How to find which data change is causing a SwiftUI view to update
How to fix “Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type” | SwiftUI by Example
How to fix “Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type”