English subtitles

← Hiding the Stop Button - Intro to iOS App Development with Swift

Get Embed Code
3 Languages

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

  1. The correct answer here is viewWillAppear as this is
  2. the method where we show and hide things on our phone.
  3. Now, if you look at our class, this method, viewWillAppear, does not exist yet.
  4. As I start typing it, however, Xcode actually autocompletes the method for
  5. me and I can accept that autocomplete suggestion by hitting Enter.
  6. There. This method viewWillAppear is inherited from UIViewController, and
  7. that is why this keyword override is used.
  8. Now in here, I want to hide the stop button.
  9. To do this, I will need to access the stop button in the code somehow.
  10. And the way I can do that is by pressing Control on my keyboard and
  11. creating an outlet at the top here.
  12. I will call it stopButton and hit Connect.
  13. Okay, I'm going to scroll up a little bit so we can see all of the code,
  14. and inside viewWillAppear, I will hide the stop button.
  15. Now, one last thing I want to do here is I want to make sure that
  16. the stop button actually starts to show up when I press this microphone button.
  17. So remember when I press this microphone button, this action gets called.
  18. So in here, I'll say stopButton.hidden is equal to false.
  19. Let me run this and see if it works.
  20. All right, so when the app first launches, I do not see any stop button.
  21. That is good.
  22. When I click on this microphone, the stop button starts showing.
  23. That is great.