Please conduct the following tasks alone. For implementation details you can refer to the lecture slides or the Apple developer website. Please do not hesitate to ask me or the tutor if you have any questions. Under “Tip” you can find some hints for the task. The “Checklist” specifies what should happen when your implementation is correct.
Create an app with a text field, a button and a label that greets the user when tapping the button. The user has to enter his name in the text field first. When button is tapped, the text written in the text field should be displayed on the label. The keyboard should be hidden, when the button is tapped and when the user taps on the „Return“-key on the keyboard. The keyboard shall also be hidden, when the user taps on empty space on the display.
Use a UITextField, a UILabel and a UIButton. To connect the text field and the label to the view controller use outlets. The action of the button can be triggered using an IBAction. To hide the keyboard call resignFirstResponder() on the UITextField. To handle touch events on the view itself, look in the iOS documentation and search for the UIResponder class which is the parent class of a view or look at the slides.
Checklist | |
---|---|
Text field exists | |
Label exists | |
Button exists | |
On tap of the button, the label is greeting the name from the text field | |
On tap of the button, on the return key or on the blank screen the keyboard is dismissed |