Recall & Review
beginner
What is programmatic navigation in iOS Swift?
Programmatic navigation means moving between screens (view controllers) using code instead of storyboard segues. It lets you control when and how to show new screens.
Click to reveal answer
beginner
Which method is used to push a new view controller onto the navigation stack?
You use
navigationController?.pushViewController(_:animated:) to show a new screen by adding it on top of the current one.Click to reveal answer
beginner
How do you present a view controller modally in Swift?
Use
present(_:animated:completion:) on the current view controller to show another screen that covers it, like a popup or full screen.Click to reveal answer
intermediate
What is the difference between pushing and presenting a view controller?
Pushing adds a screen to the navigation stack with a back button. Presenting shows a screen modally without a back button, often for temporary tasks.
Click to reveal answer
intermediate
Why is it important to check if
navigationController is not nil before pushing?Because pushing only works if the current view controller is inside a navigation controller. If nil, pushing will fail and crash the app.
Click to reveal answer
Which method do you use to navigate to a new screen by adding it to the navigation stack?
✗ Incorrect
pushViewController(_:animated:) adds a new view controller on top of the navigation stack.
What happens when you call
present(_:animated:completion:)?✗ Incorrect
present(_:animated:completion:) shows a new screen modally, covering the current screen.
Before pushing a view controller, you should check if:
✗ Incorrect
You must ensure navigationController is not nil to push safely.
Which navigation style provides a back button automatically?
✗ Incorrect
Pushing on a navigation stack adds a back button to return to the previous screen.
To close a modally presented view controller, you use:
✗ Incorrect
dismiss(animated:completion:) closes a modally presented view controller.
Explain how to navigate from one screen to another programmatically in iOS using Swift.
Think about the two main ways: pushing on navigation stack and presenting modally.
You got /4 concepts.
Describe the difference between pushing a view controller and presenting it modally.
Consider how the user returns to the previous screen in each case.
You got /4 concepts.