Which of the following best explains why a Navigation Controller is important for app flow in iOS?
Think about how users move between different pages or screens in an app.
A Navigation Controller manages a stack of screens, letting users navigate forward and backward smoothly. This structure organizes the app flow clearly.
In an iOS app, when you push a new view controller onto a Navigation Controller, what is the visible result?
Consider how iPhone apps usually show new pages and allow going back.
Pushing a view controller slides the new screen in from the right and adds a back button, so users can return to the previous screen easily.
When navigating between view controllers using a Navigation Controller, which lifecycle method is called on the previous view controller when a new one is pushed?
Think about what happens to the old screen when a new screen covers it.
When a new view controller is pushed, the previous one calls viewWillDisappear(_:) because it is about to be hidden.
In an iOS app using a Navigation Controller, what happens when you pop a view controller?
Think about the back button behavior in apps.
Popping removes the top screen from the stack, revealing the screen underneath, allowing users to go back.
Consider this Swift code snippet in an iOS app:
let detailVC = DetailViewController() navigationController!.pushViewController(detailVC, animated: true)
Why might this cause a crash when run?
Check if the current screen is inside a Navigation Controller before pushing.
If navigationController is nil, calling pushViewController causes a crash because there is no navigation stack to push onto.