English subtitles

← Picking Images - UIKit Fundamentals

Get Embed Code
3 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. When you have a complex project,
  2. it's important to approach it
    one small piece at a time.
  3. We don't recommend that you jump
    straight into writing meme.
  4. It's easier to experiment
    if you create a temporary
  5. X code project that you
    don't plan on keeping.
  6. To learn to pick images, for
    example, you might want to create
  7. a one button app that picks and
    displays a single image,
  8. the smallest possible project that will
    let you learn what you need to know.
  9. Baby steps to the meme generator.
  10. So here I've made a simple
    project to experiment with, and
  11. since the meme editor has a toolbar
    at the bottom of the screen,
  12. I'm going to go ahead and
    drag one of those in.
  13. And I'll position it and
    set its constraints.
  14. The tool bar comes with this button,
    but I'm going to go head and
  15. change its label to pick.
  16. And you see I've already got an image
    view, so you can go head and
  17. drag one of those in and
    set its constraints.
  18. Now I'm going to close this
    outline view for a minute and
  19. open up the assistant editor, and then
    we can add an outlet for our image view.
  20. Now, let's go down to our button, and
    we'll add an action for our button.
  21. Let's call it pickAnImage.
  22. And that ought to do it for Storyboard.
  23. So, we'll focus on our
    view controller file.
  24. I'm going to get rid of this
    extra method for now, and
  25. here in the pick and image method
    that we just added, we want to launch
  26. out UI image picker controller,
    just like we did in lesson two.
  27. So we add these two lines to present
    the image picker and let's run it and
  28. see how it looks.
  29. And there we go.
  30. We can choose from our outlets.
  31. So we're making progress, but
  32. when I choose a picture, I can't
    really tell that it's being chosen.
  33. We still need to implement
    the delegate pattern, and
  34. set our view controller as
    the delegate of the image picker.
  35. Next step, we'll investigate
    the delegate protocol so
  36. we'll know what method will be called
    when the picker has an image chosen.