1/27

Lecture Mobile Application Development (119310)

iOS Development - Framework Basics Part I

2/27

Agenda

3/27

iOS Application Framework Layers

center

4/27

iOS App Components

5/27

iOS Project Files

center

6/27

Interface Builder

7/27

XIB

center

8/27

Storyboards

  • Allows to define views and segues (including transitions) graphically in Interface Builder

  • StoryBoards are ideal for rapid prototyping

  • Following main types of segues exist:

    • Show - can only be used within a view managed by a NavigationController
    • Present Modally - opens view as a new modal view. Different transitions can be selected
    • Show Detail / Present as Popover are similar
    • Custom - requires own implementation of 
UIStoryboardSegue class. Can be used with NavigationController

center

9/27

UI Components

10/27

Storyboards Assignment

11/27

UIKit

12/27

UIView & UIWindow

13/27

UIView & UIWindow

center

Source

14/27

Core Animation

  • Uses „layer“ objects that render the content of your view into a bitmap
  • Layers can be easily animated using full power of the graphics hardware
  • Animations modify the 
properties of the layer over time
  • You can use it to change the 
opacity, the position and
the size and orientation of the layer on screen

15/27

The App Delegate

16/27

App Delegate Methods

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }
17/27

UIViewController

import UIKit // UIViewController is part of the UIKit Framework

class ViewController: UIViewController {

    @IBOutlet weak var myLabel: UILabel!
    
    override func viewDidLoad() { // called when the view becomes visible
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() { // called when the system is running low on memory
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    @IBAction func buttonTouched(sender: UIButton) { // custom action method
        
        myLabel.text = "Hello Swift"
        
        
    }
}

18/27

Core Data

center 70%

19/27

Event Handling

center

Source

20/27

UIResponder

center Source

21/27

First Responder

22/27

Responder Chain

center 60% Source

23/27

Multi-Touch Event Handling

   override func touchesBegan(_: Set<UITouch>, with: UIEvent?){
        print("touches began")
    }
    
    override func touchesEnded(_: Set<UITouch>, with: UIEvent?){
        print("touches ended")
    }
    
    override func touchesMoved(_: Set<UITouch>, with: UIEvent?){
        print("touches moved")
    }
    override func touchesCancelled(_: Set<UITouch>, with: UIEvent?){
        print("touches cancelled")
    }
24/27

Control Objects Event Handling

25/27

UITextField

  @IBAction func returnPressed(sender: AnyObject) {
        myTextField.resignFirstResponder()
   }

26/27

View Controller Assignment

27/27

References