Bird
0
0

What does the pushViewController(_:animated:) method do in a UINavigationController?

easy📝 Conceptual Q11 of 15
iOS Swift - Navigation
What does the pushViewController(_:animated:) method do in a UINavigationController?
AIt removes the current screen from the navigation stack.
BIt adds a new screen on top of the current navigation stack.
CIt replaces the entire navigation stack with a new screen.
DIt resets the navigation stack to the root screen.
Step-by-Step Solution
Solution:
  1. Step 1: Understand pushViewController behavior

    The method adds a new view controller on top of the current stack, showing a new screen.
  2. Step 2: Compare with other navigation actions

    Pop removes the top screen, replace resets stack, so push only adds on top.
  3. Final Answer:

    It adds a new screen on top of the current navigation stack. -> Option B
  4. Quick Check:

    pushViewController = add new screen [OK]
Quick Trick: Push means add a new screen on top [OK]
Common Mistakes:
  • Confusing push with pop (removing screen)
  • Thinking push replaces the whole stack
  • Assuming push resets to root screen

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes