Abrindo telas com NavigationLink
Navegue para uma visualização de detalhes ao tocar.
Abrindo telas com NavigationLink é uma aula grátis de SwiftUI Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de SwiftUI Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de SwiftUI Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em 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. 🎉
Perguntas Frequentes
A aula “Abrindo telas com NavigationLink” é grátis?
Sim — o texto completo de “Abrindo telas com NavigationLink” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de SwiftUI Academy, atualize para CoddyKit PRO. O curso de SwiftUI Academy inclui 4 aulas no total.
O que vou aprender em “Abrindo telas com NavigationLink”?
Navegue para uma visualização de detalhes ao tocar. Você pratica SwiftUI Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar SwiftUI Academy?
Nenhuma experiência prévia é necessária. SwiftUI Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.
Quanto tempo leva a aula “Abrindo telas com NavigationLink”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de SwiftUI Academy?
Sim. Cada aula de SwiftUI Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Abrindo telas com NavigationLink
- Passando dados para visualizações de detalhes
- Barra de ferramentas e título de navegação
- Caminhos de navegação programática