Like using a label with code, you can also respond to a button press with code. The process is slightly different from that of the label, and this video explains the difference and shows how to respond to a button press.
- [Instructor] Let's say instead of modifying…the label right when the app launches,…you wanted to modify it when a button is pressed,…or in other words, when some type of event occurs.…Let's do that by creating a button first.…Let's head over to Main.storyboard and create a button…by clicking that library button, filtering for button,…and then just click and drag that onto the screen.…I'll drag it below the label.…Then I'm gonna change the button's…text by double clicking it.…I'll double click, say Change Label in here,…press Return to commit the change.…
Then I'll need to realign it, that looks good.…Now, we wanna connect this to our code.…Now, you generally use the same process…to connect a button to your code as you do for a label,…but rather than manipulating the button when our code runs,…we just want to respond to the button event.…In other words, when the button is pressed by the user.…Instead of being an outlet like our label was,…this is going to be an action connection.…So, we're not necessarily connecting the button…
- Installing and using Xcode
- Working with storyboards
- Working with UI objects and events
- Resizing objects and layouts dynamically
- Coding UI objects such as buttons
- Loading and displaying data in table views
- Testing your iOS app
Skill Level Beginner
1. Xcode Fundamentals
2. Core Skills
3. Responsive UI Design
4. Coding UI Objects
5. Table Views
6. App Flow and Testing
Next steps1m 8s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.