UIKit Fundamentals Flashcards

1
Q

What is the course outline of UIKit Fundamentals

A
  1. Outlets and Actions
  2. Presenting View Controllers
  3. The Delegate Pattern
  4. Tables
  5. Navigation
  6. MemeMe Techniques
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A
  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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a property?

What is an action?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does marking a variable as an IBOutlet do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe a simple red, green, blue colour combining app

A
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.
[]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe the sequence in the ColorMaker app

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are delegates used for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain what the following methods do;

textFieldDidBeginEditing
textFieldDidEndEditing
shouldChangeCharactersInRange
textFieldShouldReturn

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly