0
0
iOS Swiftmobile~5 mins

Programmatic navigation in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ApopViewController(animated:)
Bpresent(_:animated:completion:)
CpushViewController(_:animated:)
Ddismiss(animated:completion:)
What happens when you call present(_:animated:completion:)?
AIt pushes a new screen with a back button.
BIt shows a new screen modally over the current one.
CIt removes the current screen.
DIt reloads the current screen.
Before pushing a view controller, you should check if:
AThe app is in background.
BThe view controller is nil.
CThe view controller is already visible.
DThe navigationController property is not nil.
Which navigation style provides a back button automatically?
APushing on navigation stack
BModal presentation
CPresenting a popover
DReplacing root view controller
To close a modally presented view controller, you use:
Adismiss(animated:completion:)
BpushViewController(_:animated:)
CpopViewController(animated:)
Dpresent(_:animated:completion:)
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.