UIKit Fundamentals Flashcards Preview

Programming > UIKit Fundamentals > Flashcards

Flashcards in UIKit Fundamentals Deck (14):
1

What is the course outline of UIKit Fundamentals

1. Outlets and Actions
2. Presenting View Controllers
3. The Delegate Pattern
4. Tables
5. Navigation
6. MemeMe Techniques

2

What 3 pieces of information do target actions perform (eg IBAction / tapped button)

1. An object to notify - ie a target (eg the ViewController)

2. A method to use - ie an action

3. The event that will trigger the target/action

3

Look back over videos from video 8-15 - lesson 1

Look back over videos from video 8-15 - lesson 1

4

What is a property?

What is an action?

An property is an outlet.
(see below)

import UIKit
class ViewController: UIViewController {

// properties are below - eg 'colourView: UIView!]
@IBOutlet weak var colorView: UIView!
@IBOutlet weak var redControl: UISwitch!

An action is a method.

5

What does marking a variable as an IBOutlet do?

Marking a variable as an IBOutlet makes it visible in Storyboard.

6

Does every view in Storyboard need an outlet? Why or why not?

A view in Storyboard needs an outlet if it needs to be modified programmatically.

7

Does every view in Storyboard need an action? Why or why not?

A view in Storyboard needs an action if it is expected to respond to user input.

8

Describe a simple red, green, blue colour combining app

Create 3 controls...
-R i/o
-G i/o
-B i/o
...hoooked up to 3 outlets. Then route the events from all three into a single action...

...a square view that changes colour.
[]

9

What is the name of the event that corresponds the the switch been thrown?

valueChanged

As with UISlider, when the user manipulates the switch control (“flips” it) a valueChanged event is generated, which results in the control (if properly configured) sending an action message.

Type property:
valueChanged = A touch dragging or otherwise manipulating a control, causing it to emit a series of different values.

10

How do we know if the switch is on or off?

We know the switch is on or off with the...

"isOn" property

isOn -
A Boolean value that determines the off/on state of the switch.

Declaration -
var isOn: Bool { get set }

This property allows you to retrieve and set (without animation) a value determining whether the UISwitch object is on or off.

11

Describe the sequence in the ColorMaker app

The user touches one of the switches, and the switches turns that tap into events.

This triggers the target actions that we set.

An action will be invoked on the (main) ViewController, and in that method the ViewController looks at the state of all three switches. That determines the background colour that the ViewController will set on the colourView (the rectangle under the switches that changes colour).

So we need outlets to get the states of the three switches (ViewController connecting to the switches), and we need an outlet for the colorView (ViewController connecting to the rectangle to change colour). We also needs to set actions (ie methods) for each switch.

12

What are our options in iOS for presenting a UI with multiple pages of content?

Our two options for presenting a UI with multiple pages of content are.

1. Navigation; Implementing a navigation structure (screen slides form left to right)

2. Modal; Modal presentation - screen pops up (eg slide from bottom, often used for alert views)

13

What are delegates used for?

To make important connections between model, view, and controller.

A delegate is an object that executes a group of messages on behalf of another object.

We want view classes to be uses as is, and then we want control and model classes to have the freedom to customise those views.

The key to the delegate pattern is that the view establishes the questions that it needs answered, and encodes them in a protocol (a protocol is a list of methods that the delegate must implement). Any object that fulfills the protocol can become a delegate.

14

Explain what the following methods do;

textFieldDidBeginEditing
textFieldDidEndEditing
shouldChangeCharactersInRange
textFieldShouldReturn

The method textFieldDidBeginEditing is called as soon as the user taps inside a textfield.

The method textFieldDidEndEditing is often used to save text to a data model.

The methodshouldChangeCharactersInRange is called when a user types a new character into the textfield or deletes a character.
For example, this method would be called when a user types the letter "t" in "cat" or the letter "d" in "red". ("cat" changes to cat emoji etc)

The method textFieldShouldReturn is called when a user taps the return button.