0Pricing
SwiftUI Academy · Lección

Navegación a pantallas con NavigationLink

Navegue a una vista de detalles al pulsar.

Navegación a pantallas con NavigationLink es una lección gratuita de SwiftUI Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de SwiftUI Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de SwiftUI Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

Screens That Stack

Real apps move between screens. In SwiftUI you wrap your content in a NavigationStack so you can push new screens on top and slide back. 📱

NavigationStack {
    HomeView()
}

What NavigationLink Does

A NavigationLink is a tappable label that pushes a new view onto the stack. Tap it and the next screen slides in from the right.

NavigationLink("Details") {
    DetailView()
}

Link Lives Inside the Stack

A NavigationLink only works when it sits inside a NavigationStack. Without that wrapper, the tap has nowhere to push to and nothing happens.

NavigationStack {
    NavigationLink("Open") { DetailView() }
}

A Custom Label

The link label can be any view, not just text. Give the label closure a row of icon and text to make the tap target feel rich.

NavigationLink {
    DetailView()
} label: {
    Label("Profile", systemImage: "person")
}

The Destination Closure

The first closure is the destination: the screen that appears when tapped. SwiftUI builds it lazily, only when the user actually navigates.

NavigationLink {
    SettingsView()
} label: {
    Text("Settings")
}

The Back Button Is Free

You never build the back button yourself. The stack adds a back button automatically, and swiping from the left edge also returns to the previous screen. 👍

Links Inside Lists

Links shine in a List. Each row becomes tappable and gets a chevron, giving you the classic iOS drill-down feel for free.

List {
    NavigationLink("Inbox") { InboxView() }
    NavigationLink("Sent") { SentView() }
}

Push, Do Not Replace

Pushing adds a screen on top of the stack rather than replacing the current one. That is why the back button can return you exactly where you were.

Nesting Goes Deep

A pushed screen can hold its own links, so users can drill down level after level. The stack remembers the whole path and unwinds it one tap at a time.

Keep One Stack Per Flow

Put a single NavigationStack at the root of each navigation flow. Nesting stacks inside each other usually causes confusing, broken back behavior.

A Tiny Mistake to Avoid

Forgetting the surrounding NavigationStack is the most common beginner bug. The link renders but tapping it does nothing, so always check the wrapper first.

Quick Check

Where must a NavigationLink live to actually push a screen?

Recap: Pushing Screens

You wrap content in a NavigationStack and use NavigationLink to push detail screens, with the back button handled for you. Next, you will pass data along. 🎉

Preguntas frecuentes

¿La lección «Navegación a pantallas con NavigationLink» es gratis?

Sí — el texto completo de «Navegación a pantallas con NavigationLink» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de SwiftUI Academy, actualiza a CoddyKit PRO. El curso de SwiftUI Academy incluye 4 lecciones en total.

¿Qué aprenderé en «Navegación a pantallas con NavigationLink»?

Navegue a una vista de detalles al pulsar. Practicas SwiftUI Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar SwiftUI Academy?

No se requiere experiencia previa. SwiftUI Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.

¿Cuánto tiempo toma la lección «Navegación a pantallas con NavigationLink»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de SwiftUI Academy?

Sí. Cada lección de SwiftUI Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. Navegación a pantallas con NavigationLink
  2. Pasar datos a vistas de detalles
  3. Barra de herramientas y título de navegación
  4. Rutas de navegación programática
← Volver a SwiftUI Academy