Chapter 13 UI Navigation Controller

Drill-down interface: is an interface that contains multiple related screens. For example the settings applications has a list of different settings that can be adjusted, when you click on an item you are taken to a different screen in which you can adjust smaller details of the item.

UINavigationController- allows for an easy transition between views. A back button and animation are automatically added to the transitioning views. UINavigationController’s stack is an array.

A keyboard’s appearance based on touch is built into the UITextField and UITextView class. In this chapter we learn how to hide the keyboard based on touching the return button or background.

Touch event– is an event created by touch.

UINavigationBar-location of objects to help navigate between views.


Download the PDF file .

Chapter 11 Subclassing UITableViewCell

Creating an ItemCell

  • Once ItemCell is defined, open its attributes inspector and change the Style to Custom and Identifier to ItemCell.
  • Then open the inspector, enter ItemCell in the class field.
  • Change the prototype cell to be 65pts tall
  • Add 3 labels to the prototype and configure them so that two are above each other on the left and one is on the right aligned with the top left label

Add constraints:

  1. Select the top-left label and open the pin menu. Select the top and left struct and then click add 2 constraints.
  2. Control + drag from the bottom-left label to the top-left label and select Leading.
  3. With bottom-left selected, open the pin menu and select the bottom-struct and add 1 constraint.
  4. Select the right label and control + drag from this label to the superview on its right side. Select both trailing space to container margin and center vertically in container.
  5. Select bottom-left label and open its size inspector. Find the Vertical Content Hugging Priority and lower it to 250. Lower the Vertical Content Compression Resistance Priority 749.
  6. If frames are misplaced update frames in the resolve auto layout issue menu.

In Item Cell 3 outlets were added. An updateLabels function was added so that the cells respond to user input such as changes in text size as show in the clip below. In viewDidLoad, set the height of the table view cells dynamically so that each cell is adjusted to the contraints.

Dynamic Type – allows for automatic resizing of cells

Download the PDF file .

Chapter 8 Controlling Animations

Animation – the act of bringing to life.

In the Xcode’s open the help menu and select documentation. Search for UIView Class Reference and scroll to the section titled Animation. This section gives animation recommendations and a list of UIView properties that can be animated.

Basic Animation

Basic Animation – animates between a start and end value.

  • ex/ class func animateWithDuration(duration:NSTimeInterval, animations:() ->Void);
  • This is the simplest UIView animation method. The class takes two arguments duration of type NSTimeInterval (Double) and animation variable for closure.


Closure – is a discrete bundle of functionality that can be passed around your code. Functions and methods are a special case of closures.

  • allows easy passing of arguments to functions and can be a return type of a function or method

A closure is a comma separated list of arguments with parentheses followed by return arrow and return type.

  • ex/ (arguments) -> return type

This differs from the syntax of a function: func function(arguments) -> return type

Closure signature that animation argument expects, this closure takes in no argument and doesn’t return anything:

class func animateWithDuration(duration:NSTimeInterval, animations:() ->Void);

To declare a closure in code: {(arguments) -> return type in //code }

Anonymously – passing closure directly into the method instead of assigning it to a variable or constant.

Another Label

Add the following lines of code to the ViewController.swift file to add another label to transition to.

screen-shot-2016-10-14-at-11-24-31-am screen-shot-2016-10-14-at-11-24-43-am screen-shot-2016-10-14-at-11-25-12-am

Animation Completion

This can be important if you need to know when an animation is completed. For example if you want to program an animation’s start after another animation ends. To do this a closure will need to be passed for the completion argument. Like so:


Delay indicates how long the system should wait before triggering the animation.

Animation Contraints

Animating constraints involves animating where the object located rather than how the object appears or disappears.

First you need a reference to the constraint to be modified. Declare two outlets for the label’s centering constraints in the ViewController.swift file.


In the Main.storyboard connect the outlets to their constraints.

  • Control + drag from View Controller to Current Question Label.centerX and do the same for Next Question Label.centerX.
  • Delete currentQuestionLabel.
  • Then Control + drag upwards from Next Question button and select Center Horizontally in Container.

To move the constraints from their position implement the following code in the ViewController.swift file.


Each time a constraint is modified, you must ask the system to update the frames. You do this by calling layoutIfNeeded() on a view. Update the following in the ViewController.swift file.


To fix a difficult to see bug add the following to the top of the animateLabelTransitions() method.

//Force any outstanding layout changes to occur


Timing Functions

By default animations use an ease-in/ease-out timing function. Other options are:

  • Linear– constant speed from beginning to end (.CurveLinear)
  • Ease-in– accelerating to constant speed and then ending abruptly (.CurveEaseIn)
  • Ease-out– beginning at full speed and then slowing down at the end (.CurveEaseOut)
  • Ease-in/Ease-out- (.CurveEaseInOut)
  • Allow user interaction– by default views cannot be interacted with when animating, this option overrides the default (.AllowUserInteraction)
  • Repeat– repeats animation indefinitely (.Repeat)
  • Autoreverse– runs animation forward and backwards and returns initial state (.Autoreverse)
  • there are more options in the Constants section of the UIView Class Reference


Hi my name is Chelsea Irizarry and I am working on an independent study on iOS application development for Apple products. I am a current undergrad student at University of Mary Washington studying computer science. I will be walking through the iOS Programming: The Big Nerd Ranch Guide 5th Edition following the schedule. I will be posting a lot of information about the iOS programming throughout the semester. If you have any questions feel free to contact me using the contact form the site.

Swam Sunrise

Swamp Sunrise

Flickr Album Gallery Powered By: Weblizar