فتح الشاشات باستخدام NavigationLink
انتقل إلى View التفاصيل عند النقر
فتح الشاشات باستخدام 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»؟
انتقل إلى View التفاصيل عند النقر تتمرن على SwiftUI Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ SwiftUI Academy؟
لا تُشترط خبرة سابقة. SwiftUI Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «فتح الشاشات باستخدام NavigationLink»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس SwiftUI Academy هذا؟
نعم. كل درس في SwiftUI Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- فتح الشاشات باستخدام NavigationLink
- تمرير البيانات إلى View التفاصيل
- شريط الأدوات وعنوان التنقل
- مسارات التنقل البرمجية