Bird
0
0

What is the expected behavior when the user taps the text "Settings" in this SwiftUI code?

medium📝 Predict Output Q4 of 15
iOS Swift - Navigation
What is the expected behavior when the user taps the text "Settings" in this SwiftUI code?
NavigationView {
  NavigationLink(destination: Text("Settings Page")) {
    Text("Settings")
  }
}
ANothing happens because NavigationLink is missing a label.
BThe app navigates to a new view displaying "Settings Page" text.
CThe app crashes due to missing NavigationView.
DThe text "Settings" changes color but no navigation occurs.
Step-by-Step Solution
Solution:
  1. Step 1: Identify NavigationLink behavior

    Tapping the label triggers navigation to the destination view.
  2. Step 2: Confirm NavigationView presence

    Since the NavigationLink is inside a NavigationView, navigation works correctly.
  3. Final Answer:

    The app navigates to a new view displaying "Settings Page" text. -> Option B
  4. Quick Check:

    NavigationLink inside NavigationView navigates on tap [OK]
Quick Trick: NavigationLink inside NavigationView navigates on tap [OK]
Common Mistakes:
  • Assuming NavigationLink needs explicit action
  • Forgetting NavigationView wrapper
  • Confusing label and destination roles

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes