0Pricing
SwiftUI Academy · Lektion

Programmgesteuerte Navigationspfade

Steuern Sie die Navigation mit einem navigationDestination-Pfad.

Programmgesteuerte Navigationspfade ist eine kostenlose SwiftUI Academy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des SwiftUI Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der SwiftUI Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Navigating From Code

Sometimes a tap is not enough. After saving a form you may want to jump screens yourself. SwiftUI lets you drive the stack from code. ⚙️

A Path You Control

Give NavigationStack a path binding. This array is the live list of screens currently pushed, and editing it changes navigation instantly.

@State private var path = NavigationPath()
NavigationStack(path: $path) { HomeView() }

Push by Appending

Append a value to the path and SwiftUI pushes the matching screen. No tap needed, just change the array.

path.append(book)

Routing the Value

A navigationDestination maps each value type in the path to a view, so appended data knows which screen to become.

.navigationDestination(for: Book.self) { book in
    DetailView(book: book)
}

Pop With Remove

Removing the last element pops a screen, exactly like the back button. You stay in full control of the stack from code.

path.removeLast()

Jump Home Instantly

To return all the way to the root, empty the path. Every pushed screen disappears at once, perfect for a Done button. 🏠

path.removeLast(path.count)

Deep Linking

Because the path is just data, you can build it from a URL or notification, pushing several screens so users land deep inside the app.

NavigationPath Holds Mixed Types

A NavigationPath can store values of different types together, letting one stack route books, users, and settings without a shared enum.

Or Use a Typed Array

If every screen shares one type, a plain typed array works as the path and reads a little more clearly than NavigationPath.

@State private var path: [Book] = []

State Drives the Stack

Navigation becomes state. The visible screens always mirror the path array, so your UI stays predictable and easy to reason about.

Test and Restore

Since the path is plain data, you can save it and restore it, recreating exactly where the user left off when they reopen the app.

Quick Check

What happens when you append a value to a NavigationStack path?

Recap: Programmatic Paths

You bind a path to NavigationStack and push or pop screens by editing that array, turning navigation into predictable, testable state. 🎉

Häufig gestellte Fragen

Ist die Lektion „Programmgesteuerte Navigationspfade“ kostenlos?

Ja — der vollständige Text von „Programmgesteuerte Navigationspfade“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des SwiftUI Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der SwiftUI Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Programmgesteuerte Navigationspfade“?

Steuern Sie die Navigation mit einem navigationDestination-Pfad. Du übst SwiftUI Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um SwiftUI Academy zu starten?

Keine Vorkenntnisse erforderlich. SwiftUI Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Programmgesteuerte Navigationspfade“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser SwiftUI Academy-Lektion Code schreiben und ausführen?

Ja. Jede SwiftUI Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Mit NavigationLink zu Bildschirmen wechseln
  2. Daten an Detailansichten übergeben
  3. Toolbar und Navigationstitel
  4. Programmgesteuerte Navigationspfade
← Zurück zu SwiftUI Academy