0Pricing
SwiftUI Academy · Урок

Переход между экранами с NavigationLink

Переходите к подробному представлению по нажатию.

«Переход между экранами с NavigationLink» — бесплатный урок SwiftUI Academy на CoddyKit. Это урок 1 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения SwiftUI Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс SwiftUI Academy содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

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. 🎉

Часто задаваемые вопросы

Урок «Переход между экранами с NavigationLink» бесплатный?

Да — полный текст урока «Переход между экранами с NavigationLink» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс SwiftUI Academy, подпишись на CoddyKit PRO. Курс SwiftUI Academy содержит 4 уроков всего.

Чему я научусь в уроке «Переход между экранами с NavigationLink»?

Переходите к подробному представлению по нажатию. Ты практикуешь SwiftUI Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать SwiftUI Academy?

Предыдущий опыт не требуется. SwiftUI Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 1 из 4.

Сколько времени занимает урок «Переход между экранами с NavigationLink»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке SwiftUI Academy?

Да. Каждый урок SwiftUI Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Переход между экранами с NavigationLink
  2. Передача данных в подробные представления
  3. Панель инструментов и заголовок навигации
  4. Программные пути навигации
← Назад к SwiftUI Academy