Like using a text view with code, you can also respond to a button press with code. The process is slightly different from that of the text view and this video explains the difference and shows how to respond to a button press.
- [Instructor] Our user interface has this text view, … but it also has a button. … Now, currently this button is not connected to anything. … When you press it, nothing will happen. … Simply changing the icon to a picture of a trash can … doesn't add any kind of interactivity. … We actually have to add that manually. … So, to connect a button to code, … we pretty much do the same thing as we do for a text view … or any other user interface element. … You can use the assistant editor, … and right-click and drag from that button into your code. … Now, here's something that's really important to note: … what did you select when you dragged over? … I right-clicked and dragged from the button, … but it says right here the Type is UIToolbar. … The Type refers to a code type, … just like our text view is called a UITextView in code, … toolbar is called a UIToolbar. … The problem with that is we want a button, … and if you see UIToolbar down here and Outlet up here, … that means you right-clicked …
- Creating an Xcode project
- Navigating the Xcode interface
- Running your first app
- Building layouts with storyboards
- Connecting UI elements to code
- Coding interactivity