English subtitles

← 05-06 Adding Start Over button: Step 2

05-06 Adding Start Over button: Step 2

Get Embed Code
1 Language

Showing Revision 2 created 04/08/2015 by Udacity Robot.

  1. Now let's implement
    the start over method.
  2. How should we implement this method?
  3. Which class should be responsible for
    navigating back to the root of the app?
  4. In this case, the answer is the UI
    navigation controller class.
  5. Each view controller has
    a navigation controller property.
  6. It's an optional that references
    the navigation controller that
  7. a given view controller is embedded in.
  8. When a view controller receives
    the invocation to start over,
  9. it can communicate with
    the navigationController.
  10. And here you can see the careful
    unwrapping of the optional.
  11. We could just pop off the current
    viewController like this, but
  12. we want to go all the way
    back to the beginning.
  13. So we call popToRootViewController.
  14. Here's a recap of the two
    properties we just learned about.
  15. The navigation item property
    specifies features of the nav bar.
  16. The navigation controller property
    provides a reference back to
  17. the navigation controller for
  18. programmatic control of
    view controller popping.
  19. Now take some time to get to
    know these properties and
  20. get that start over button working for
    all the end points in your story.