Mobile Development Lab 3

Size: px
Start display at page:

Download "Mobile Development Lab 3"

Transcription

1 Mobile Development Lab 3 Objectives Illustrate closures through examples Have fun with maps, location and geolocation Have fun with animations Closures implemented in Swift Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages. Closures are used in Swift/Cocoa on various frameworks, it is useful to understand their use for various tasks. In this lab work, we will introduce closures for both geolocation and animations purposes. There are three kinds of closures: global functions have a name and cannot capture any values nested functions have a name and can capture values from their enclosing functions closure expressions don t have a name and can capture values from their context We show below multiple valid syntaxes for closures: implicits and shorthands allow to simplify syntax but with a loose of readability. For clarity, we declare the closures, but usually they are used inline, i.e.: directly as an argument function. var oneparameterandreturnvalue = { (x: Int) -> Int in return x % 10 var oneparameterandreturnvalueimplicit = { (x) -> Int in return x % 10 var oneparameterandreturnvalueshortcut = { return $0 % 10 var multipleparametersandreturnvalueimplicit = { (first, second) -> String in return first + " " + second var multipleparametersandreturnvalueshorthand = { return $0 + " " + $1 Closures are also useful to work with arrays. Similarly to lambdas in Python language, closures allow to map, filter, reduce arrays items. They are also useful to apply any function taking a function as argument (ie: sorting an array). - Consider that we need to sort an array of numbers. let numbers = [10, 3, 2, 5, 1, 4] - We could declare a closure for that and call it within sorted array s function: var sortfunc: (Int, Int) -> Bool = { (num1, num2) in return num1 < num2 numbers.sorted(by: sortfunc) Note: As sorted function is called on an array of Int, Xcode s completion asks for the by argument to have type (Int, Int) -> Bool - The closure could also be defined inline: numbers.sorted(by: { (num1, num2) in

2 return num1 < num2 ) - And syntax could be minimalized with implicits and shorthands: numbers.sorted{ $0 < $1 In the previous lab work, remember that we had to modify one by one the items of an array (we had to escape-decoding an array obtained from a JSON dictionary). And we used enumeration: for (i, name) in namesarray.enumerated() { // replace escape characters namesarray[i] = name.removingpercentencoding! Closures could have been useful with array s map function: namesarray.map({ (name) -> String in name.removingpercentencoding! ) With trailing closure, we don t need parenthesis: namesarray.map{ (name) -> String in name.removingpercentencoding! And with shorthand, it s much more shortened: namesarray.map{$0.removingpercentencoding! A geocoding and geolocation project We will now make a mobile application that go further in using closures on Cocoa frameworks. Maps, location and geolocation are features that can (more or less) only be implemented in mobile apps. We will first use Apple s Geocoder service to obtain latitude/longitude of a given address. Then, using delegation, we will track user s location and display on a map view. Still with closures, we will add UIView s animations to obtain a nice looking app. - Create a new project with template Single View Application ; name it MyGeoTracker - As we will use maps, we need to link our project with MapKit framework: several option for this. One simple, in Project s setting window, select tab Capabilities, and swich on Maps. - In top of ViewController.swift, add: import MapKit - Still in ViewController.swift, declare outlets for one UITextField and a MKMapView, add the corresponding UI object in Storyboard and connect var addresstextfield: var mymapview: MKMapView! - We ll need to trigger a function when Enter key is pressed from adressetextfield: add the needed delegate. Handling geocoding - Declare a variable property of class CLGeocoder and read its documentation s description. let geocoder = CLGeocoder() Let s first implement a simple forward-geocoding feature: given a address, move the map to the corresponding location. - Add a function forwardgeocoding(withaddress:) taking a String as argument:

3 func fowardgeocodding(withaddress address:string) { - Call this function from textfieldshouldreturn(). Let s now implement our function forwardgeocoding(withaddress:) and use the geocoder object. The needed function uses a closure as completion handler. In closure, note that we only need its first variable, so we just ignore the second (with _ ). The first closure s variable placemarks is an optional array of CLPlacemark. The array may have zero item if nothing is found, or may have multiple items in case where multiple locations respond to the same given address. For safety, we need to use it within a if-let statement, and as we then get the first item (which is optional too), we unwrap everything in an optional chaining. To change the location of UIMapView, we can either set its property centercoordinate of type CLLocationCoordinate2D ; or call its function setregion() (that uses a MKCoordinateRegion and allow to animate the transition). And, an object of MKCoordinateRegion is constructed from CLLocationCoordinate2D and region s size in meters: geocoder.geocodeaddressstring(address, completionhandler: { placemarks, _ in ) if let placemark = placemarks?.first { let coordinateregion = MKCoordinateRegionMakeWithDistance((placemark.location?.coordinate)!, 1000, 1000) self.mymapview.setregion(coordinateregion, animated: true) With closure shorthand, it s equivalent to: geocoder.geocodeaddressstring(address) { let placemarks = $0.0 // shorthand's first member if let placemark = placemarks?.first { let coordinateregion = MKCoordinateRegionMakeWithDistance((placemark.location?.coordinate)!, 1000, 1000) self.mymapview.setregion(coordinateregion, animated: true) Great! We have our first geocoding feature. Let s now add geolocation Manage Geolocation We will add a geolocation functionality to our application. The application will count the distance traveled (since his last start or reset) and will display the current position and trace the path on the map. Setting Xcode for asking user s location We first must tell Xcode to allow our app to access user s location. To protect user privacy, an ios app which accesses the user s location information, must statically declare the intent to do so. We must include the NSLocationWhenInUseUsageDescription key in the app s Info.plist file and provide a purpose string for this key. Add the following key (anywhere between existing keys): <key>nslocationwheninuseusagedescription</key> <string>this app tracks your current location, please allow!</string> The first time the app needs to access user s location, it should ask the user to allow for accessing current location with the given message. This decision can be changed at any time by the user from the Setting app. Initialization and configuration of CLLocationManager The framework CoreLocation contains a class CLLocationManager which allows to access, start and stop the different device s location resources (GPS, Heading). We need to instantiate an object of this class.

4 - In ViewController.swift, declare a variable (property) of type CLLocationManager and instanciate it with default initializer. let locationmanager = CLLocationManager() - Find in the documentation (or browse header files) to get informations about how CLLocationManager works. You found the protocol associated with this class? Indeed, CLLocationManager also uses delegation to operate. Functions startupdatinglocation() and stopupdatinglocation() are respectively used to start and stop the location service, while delegate s function locationmanager(didupdatelocations:) of CLLocationManagerDelegate is called every time the position has changed. - In our case, the class ViewController will be the delegate of CLLocationManager. Change the declaration in ViewController.swift accordingly: class ViewController: UIViewController, UITextFieldDelegate, CLLocationManagerDelegate - In viewdidload(), we can configure our locationmanager (look especially its properties distancefilter and desiredaccuracy), then add: locationmanager.delegate = self Since ios requires an authorization to access user s location and the user may change its decision at any time, we must first check the authorization status. If it is still undetermined (ie: first time launching), it is necessary to request the right permission. If the status is already valid, we can start the location service. - In viewdidload(), after locationmanager configuration, add the following statements: let status = CLLocationManager.authorizationStatus() if (status ==.notdetermined) { locationmanager.requestwheninuseauthorization() else if (status ==.authorizedwheninuse) { locationmanager.startupdatinglocation() else { print("not allowed to access current location") - At the first launch (when status is undetermined), the delegate s function locationmanager(didchangeauthorizationstatus:) is called. If everything is ok, it is time to start the location service. Add the following function: func locationmanager(_ manager: CLLocationManager, didchangeauthorization status: CLAuthorizationStatus) { if (status ==.authorizedwheninuse) { locationmanager.startupdatinglocation() else { print("not allowed to access current location") - To go further: nesspg/introduction/introduction.html

5 Looks great but nothing happens Sure, we didn t yet implement any tracking feature. Indeed, we only prepare the location manager, we will add tracking in next section. Notice that it is possible to simulate location movement on the Simulator: Menu Debug/Location/City Run... Tracking and distance travelled We will now focus on monitoring the user s location. To illustrate it, the application will count the distance traveled since the start of the service. - In ViewController.swift, add a variable totaldistance (of type Double) initialized to 0. When the position is updated, the function locationmanager(didupdatelocations:) is called. The second argument is an array that contains CLLocation items stored in chronological order (the last one is the most recent). We can compute the get the distance in meters between two CLLocation through its instance function distance(from:). - In locationmanager(didupdatelocations:) get the last item of the array locations and get its distance to the previous location. We also need to store the previous location in a class variable previouslocation. let currentlocation = locations.last! totaldistance += currentlocation.distance(from: previouslocation) previouslocation = currentlocation - Add a new UILabel to your view and display the distance traveled. Be careful, the first few calls to this method return often very far locations. You can check the estimated accuracy from properties horizontalaccuracy and verticalaccuracy, or you can just ignore the first five calls to this method. - Implement tracking in the map: the map region should follow the current location (see above how to change map s region) - Add a UISlider named zoomslider and an associated IBAction to change the map s scale. From Storyboard, set minimum value to 10 and maximum value to Change your code in order to make map s region match with slider s value. - Add a UISwitch named geofeatureswitch to pause (starts / stops) geolocation and connect it to the IBAction switchchangedvalue(). Searching for an address (geocoding) will only work when the switch is off. You might also want to write "Enter an address" in the UILabel when the switch is off and hide the UITextField when the switch is on Is it working? Great, let s now draw on the map Drawing the path If you did not already, you must first conform ViewController with the protocol MKMapViewDelegate, then add the following statement in viewdidload() mymapview.delegate = self

6 To draw on the map view, several solutions are available to us. We will use the MKMapView and MKMapViewDelegate drawing overlay feature. The "viewable" objects on the map must implement the protocol MKOverlay: we will add items of MKPolyline that implement this protocol. - In the function locationmanager(didupdatelocations:), initialize a variable MKPolyline from two points: previous and current locations. MKPolyline needs two arguments, an array of CLLocationCoordinate2D (got from CLLocation s property coordinate, and the number of items in the array (here, it is 2). Then, pass it to your mymapview using function addoverlay(). The visual rendering of these objects is determined in a second step by calling the delegate method mapview(rendererforoverlay:) (of delegate MKMapViewDelegate). Here is a way to render a MKPolyline object: func mapview(_ mapview: MKMapView, rendererfor overlay: MKOverlay) -> MKOverlayRenderer { let linerenderer = MKPolylineRenderer(overlay: overlay) linerenderer.strokecolor = UIColor.green linerenderer.linewidth = 5 return linerenderer So cool! We are now drawing on the map Let s add one more feature: gesture shaking. Reset tracking by shake gesture detection Before completing this lab, we will add one more functionality to our application: we want to reset tracking (and distance) by shaking the device. Reset consists in: - Set totaldistance variable to 0 - Remove the MKOverlay objects to the map. Look at the documentation: a MKMapView object can delete multiple MKOverlay passed as arguments in an array. We will then basically remove the array of overlays associated to our map, through mymapview.overlays. - To avoid unexpected behaviors, do reset only when UISwitch is off. Several solutions are available to us for detecting a shake. We will see a natural way to do it, based on the detection of "Gesture" (Alternatively, a lowest level solution would use CoreMotion framework). Our class ViewController inherits from UIViewController which extends UIResponder. UIResponder is the class responsible for event management (Touch, Motion,...). Because of this, we can directly override any of the methods of UIResponder. - Browse the documentation and search for the name of the function that will capture the event "Shake Motion. - Add this function in ViewController and implement the behavior described above. Let s now add a simple visual feedback to the user. The visual feedback could consist in displaying a red message "Reset tracking" for a second in our distancelabel. It means that we first change distancelabel to show the red message, then a second later we turn distancelabel to its previous settings...

7 As we seen previously in Lab 2, we could use a Timer for this purpose. We already used a timer using a selector, let s use a timer in a more modern and convenient way, using closures (here with trailing syntax): // make new string instance from existing string let previoustext = String(describing:distanceLabel.text!) distancelabel.text = "Reset tracking..." distancelabel.textcolor = UIColor.red Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { _ in self.distancelabel.text = previoustext self.distancelabel.textcolor = UIColor.black Notice that we also could use Grand Central Dispatch framework to manage asynchronous and delayed tasks, we will use it in next lab work. It should work Let s slightly improve our UI, using animations! Improving the User Interface This section aims at enriching the visual rendering of the application for a better interaction with the user. We already added a simple visual feedback on shake gesture. We'll now add few animations to show/hide our UITextField according to the UISwitch s state. Then we will change the behavior of the map: in addition to track the position, we will rotate the map with the user s direction. Animations provide visual effects required for better interaction with the user, enabling better understanding, and thus contribute to a better overall perception of application. Obviously, the animations are only related to graphic elements of UIKit. In particular, some properties are "animatable". By using simple closures, we just define the final state in which the object should be, and CoreAnimation does the intermediate rendering. Here are the animatable properties, according to the official documentation. Animating closures are called from UIView s static methods. For example, the following code changes the alpha property of adressetextfield during 0.5 seconds to the value 0:

8 UIView.animate(withDuration: 0.5, animations: { self.adressetextfield.alpha = 0 ) And again, as closure is the last argument, we can use the trailing syntax: UIView.animate(withDuration: 0.5) { self.adressetextfield.alpha = 0 The next example illustrates the use of a completion handler, which execute a second closure once animation is complete. UIView.animate(withDuration: 0.5, animations: { self.adressetextfield.alpha = 0, completion: { _ in print("addresstextfield is now hidden") ) Let s change the design of the view. Here is just a suggestion: - From Storyboard, set our UIMapView to fit the entire size of the screen; extend the UILabel, UISlider and UITextField to the entire width; put them on top of the map; set a light transparency to the UILabel and UITextField; UITextField is just below the UILabel, UISlider is between them; UISwitch button is on top-right of the screen, on top of the UILabel. - Add an animation on addresstextfield to make it visible only when the UISwitch button is off. A suggestion is to make it move to the left until disappearance.. We now focus on the map animation; we want mymapview to rotate based on the user s movements. For this purpose, we will use the heading sensor, which is also managed by CoreLocation framework. Methods locationmanager(startupdatingheading:) and stopupdatingheading() operate similarly as start/stop updating location functions: they ask locationmanager to get new heading value, which can be grabbed by locationmanager(didupdateheading:.

9 - Find these methods in the documentation. - Add the start/stop heading sensor simultaneously with the start/stop location sensor. - Add the delegate method that get update heading. Note that we obtain an object of class CLHeading whose trueheading property is particularly interesting. In order to rotate the map with the direction of the user, we will apply an affine transformation on our object MKMapView (remember that transform property is animatable). An affine transformation object (structure) is available from CoreGraphics framework, its name then starts by CG - Look in the documentation the transform property. Found it? It s a property of the UIView class (which inherits MKMapView) of type CGAffineTransform. Browse the reference to find the various initializers which define any affine transformation. There is one interesting to make rotation. - From StoryBoard, resize the map so that it is three times the size (width and height) and centered on the center of the view. So when we apply a rotation, the map will always appear in "full screen". - In the delegate function locationmanager(didupdateheading:), change the mapview s transform property to make it rotate. Beware, trueheading is in degree while CGAffineTransform uses radian. - As transform is an animatable property, you could add an animation closure to make the rotation more natural. Finally, let s tell Xcode to disable both status bar (the small bar at top of screen) and autorotation (by default, autorotation is enabled to switch between portrait and landscape modes). Override the following properties in ViewController (as you see they are computed properties ): override var prefersstatusbarhidden: Bool { return true override var shouldautorotate: Bool { return false Great, we used our first animation and our app looks great! Of course, to test this feature, you must use a real device, do not try to rotate your computer ;-) Notice that we designed our screen to one single screen s size, which is define in bottom of Storyboard ( View as: section). For a single screen, you must then arrange your UIObjects according to your preferred device (and/or simulator). For multiple screens compatibility, Xcode uses AutoLayout functionality (working with constraints), which is out of the scope here

Mobile Development - Lab 2

Mobile Development - Lab 2 Mobile Development - Lab 2 Objectives Illustrate the delegation mechanism through examples Use a simple Web service Show how to simply make a hybrid app Display data with a grid layout Delegation pattern

More information

Sensors. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Sensors. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Sensors Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Sensor types Sensor availability Accessing

More information

ITP 342 Mobile App Dev. Locations and Maps

ITP 342 Mobile App Dev. Locations and Maps ITP 342 Mobile App Dev Locations and Maps Locations and Maps Every ios device has the ability to determine where in the world it is Create a live interactive map showing any locations you like, including

More information

Maps, locations & sensors in ios

Maps, locations & sensors in ios Maps, locations & sensors in ios Sebastian Ernst, PhD Department of Applied Computer Science AGH University of Science and Technology Displaying maps (ObjC) Maps are handled by MapKit and displayed using

More information

ITP 342 Mobile App Dev. Connections

ITP 342 Mobile App Dev. Connections ITP 342 Mobile App Dev Connections User Interface Interactions First project displayed information to the user, but there was no interaction. We want the users of our app to touch UI components such as

More information

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation ITP 342 Mobile App Dev Animation Views Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. Responsibilities

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lecture 9: idevice Capabilities Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content Core Location: GPS + Compass

More information

UI Design and Storyboarding

UI Design and Storyboarding UI Design and Storyboarding Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Model-View-Controller

More information

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation ITP 342 Mobile App Dev Animation Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it

More information

Building Mapping Apps for ios With Swift

Building Mapping Apps for ios With Swift Building Mapping Apps for ios With Swift Jeff Linwood This book is for sale at http://leanpub.com/buildingmappingappsforioswithswift This version was published on 2017-09-09 This is a Leanpub book. Leanpub

More information

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney 1 Build Your First App The way to get started is to quit talking and begin doing. Walt Disney Copyright 2015 AppCoda Limited All rights reserved. Please do not distribute or share without permission. No

More information

A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController.

A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController. WordPlay App: A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController. Create a new project Create a new Xcode project

More information

Create an App that will drop PushPins onto a map based on addresses that the user inputs.

Create an App that will drop PushPins onto a map based on addresses that the user inputs. Overview Create an App that will drop PushPins onto a map based on addresses that the user inputs. Part 1: Introduction to MKMapKit Part 2: Introduction to PushPins Part 3: Use Google s API to lookup an

More information

Stream iphone Sensor Data to Adafruit IO

Stream iphone Sensor Data to Adafruit IO Stream iphone Sensor Data to Adafruit IO Created by Trevor Beaton Last updated on 2019-01-22 04:07:41 PM UTC Guide Contents Guide Contents Overview In this learn guide we will: Before we start... Downloading

More information

Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber,

Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber, 3 Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber, NSNumberFormatter and Automatic Reference Counting Objectives In this

More information

CSC 581: Mobile App Development Spring 2018

CSC 581: Mobile App Development Spring 2018 CSC 581: Mobile App Development Spring 2018 Unit 2: Introduciton to the UIKit UIKit, UIViews UIControl subclasses 1 UIKit the UIKit is a code framework for building mobile apps the foundational class for

More information

Document Version Date: 1st March, 2015

Document Version Date: 1st March, 2015 7 Minute Fitness: ios(swift) Application Document Version 1.0.1 Date: 1st March, 2015 2 [7 MINUTE FITNESS: APP DOCUMENTATION] Important Notes:... 5 AppDelegate Class Reference... 6 Tasks... 6 Instance

More information

Building the App - Part 5 - Adding a Link

Building the App - Part 5 - Adding a Link Unit 4 - Coding For Your App Copy and Paste the code below exactly where the tutorials tell you. DO NOT COPY TEXT IN RED. Building the App - Part 5 - Adding a Link XCODE 7 @IBAction func Button1(_ sender:

More information

Gerontechnology II. Collecting Smart Phone Sensor Data for Gerontechnology. Using ios

Gerontechnology II. Collecting Smart Phone Sensor Data for Gerontechnology. Using ios Gerontechnology II Collecting Smart Phone Sensor Data for Gerontechnology Using ios Introduction to ios ios devices and sensors Xcode Swift Getting started with Sensor App ios Devices ipad iphone Apple

More information

App. Chapter 19 App. App (ViewController) App. Single View Application Single View Application View. (View Controller)

App. Chapter 19 App. App (ViewController) App. Single View Application Single View Application View. (View Controller) Chapter 19 App App (ViewController) App 19.1 App App Single View Application Single View Application View Controller View Controller Label Button Button (View Controller) 2 View Controller Utility Area

More information

Enhancing your apps for the next dimension of touch

Enhancing your apps for the next dimension of touch App Frameworks #WWDC16 A Peek at 3D Touch Enhancing your apps for the next dimension of touch Session 228 Tyler Fox UIKit Frameworks Engineer Peter Hajas UIKit Frameworks Engineer 2016 Apple Inc. All rights

More information

CSC 581: Mobile App Development Spring 2019

CSC 581: Mobile App Development Spring 2019 CSC 581: Mobile App Development Spring 2019 Unit 1: Getting Started with App Development Xcode installing XCode, creating a project, MVC pattern interface builder, storyboards, object library outlets vs.

More information

Topics in Mobile Computing

Topics in Mobile Computing Topics in Mobile Computing Workshop 1I - ios Fundamental Prepared by Y.H. KWOK What is ios? From Wikipedia (http://en.wikipedia.org/wiki/ios): ios is an operating system for iphone, ipad and Apple TV.

More information

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 Questions? Announcements Assignment #1 due this evening by 11:59pm Remember, if you wish to use a free late you must email me before

More information

ITP 342 Mobile App Dev. Animation

ITP 342 Mobile App Dev. Animation ITP 342 Mobile App Dev Animation Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it

More information

Social Pinboard: ios(swift) Application

Social Pinboard: ios(swift) Application Social Pinboard: ios(swift) Application Document Version 1.0.1 Date: 15 th May, 2015 2 [SOCIAL PINBOARD: APP DOCUMENTATION] Important Notes:... 5 AppDelegate Class Reference... 6 Tasks... 6 Instance Methods...

More information

ios Development - Xcode IDE

ios Development - Xcode IDE ios Development - Xcode IDE To develop ios applications, you need to have an Apple device like MacBook Pro, Mac Mini, or any Apple device with OS X operating system, and the following Xcode It can be downloaded

More information

Why Using Location and Map? iphone Application Programming L12: Location and Maps. Why Using Location and Map? Determine where you are

Why Using Location and Map? iphone Application Programming L12: Location and Maps. Why Using Location and Map? Determine where you are Why Using Location and Map? iphone Application Programming L12: Location and Maps Chat Wacharamanotham Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone

More information

ITP 342 Mobile App Dev. Connections

ITP 342 Mobile App Dev. Connections ITP 342 Mobile App Dev Connections User Interface Interactions First project displayed information to the user, but there was no interaction. We want the users of our app to touch UI components such as

More information

CSE 438: Mobile Application Development Lab 2: Virtual Pet App

CSE 438: Mobile Application Development Lab 2: Virtual Pet App CSE 438: Mobile Application Development Lab 2: Virtual Pet App Overview In this lab, you will create an app to take care of your very own virtual pets! The app will only have one screen and simple logic,

More information

A Vertical Slider for iphone

A Vertical Slider for iphone A Vertical Slider for iphone The UISlider control offers a way to continuously get values from the user within a range of set values. In the Interface Builder library of controls, there is only a horizontal

More information

S A M P L E C H A P T E R

S A M P L E C H A P T E R SAMPLE CHAPTER Anyone Can Create an App by Wendy L. Wise Chapter 5 Copyright 2017 Manning Publications brief contents PART 1 YOUR VERY FIRST APP...1 1 Getting started 3 2 Building your first app 14 3 Your

More information

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved.

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved. Structuring an App App Development Process (page 30) Designing a User Interface (page 36) Defining the Interaction (page 42) Tutorial: Storyboards (page 47) 29 App Development Process Although the task

More information

Implementing UI Designs in Interface Builder

Implementing UI Designs in Interface Builder Developer Tools #WWDC15 Implementing UI Designs in Interface Builder Session 407 Kevin Cathey Interface Builder Engineer Tony Ricciardi Interface Builder Engineer 2015 Apple Inc. All rights reserved. Redistribution

More information

Intro to Development for ios. Dave Koziol Arbormoon Software, Inc.

Intro to Development for ios. Dave Koziol Arbormoon Software, Inc. Intro to Development for ios Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (21 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Multiple

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Error Handling in Swift try Extensions A simple, powerful, but easily overused code management syntax Protocols Last (but certainly not least important) typing

More information

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Memory Management for Reference Types Controlling when things leave the heap Closure Capture Closures capture things into the heap too Extensions A simple,

More information

Understanding the Terms Of Service

Understanding the Terms Of Service Appendix A Understanding the Terms Of Service This appendix provides an overview of the main documents and topics concerning the terms of service (TOS) of the platforms I discussed in the previous chapters.

More information

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Today Core Location Finding out where the device is MapKit Showing the location of things on a map Demo MapKit Core Location Framework for managing location and heading

More information

Event Delivery: The Responder Chain

Event Delivery: The Responder Chain When you design your app, it s likely that you want to respond to events dynamically. For example, a touch can occur in many different objects onscreen, and you have to decide which object you want to

More information

ITP 342 Mobile App Dev. Fundamentals

ITP 342 Mobile App Dev. Fundamentals ITP 342 Mobile App Dev Fundamentals Objective-C Classes Encapsulate data with the methods that operate on that data An object is a runtime instance of a class Contains its own in-memory copy of the instance

More information

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode Objectives Register for an Apple account Create an application using Xcode Test your application with the iphone simulator Import certificates for development Build your application to the device Expand

More information

ITP 342 Mobile App Dev. Collection View

ITP 342 Mobile App Dev. Collection View ITP 342 Mobile App Dev Collection View Collection View A collection view manages an ordered collection of items and presents them in a customizable layout. A collection view: Can contain optional views

More information

ITP 342 Mobile App Dev. Interface Builder in Xcode

ITP 342 Mobile App Dev. Interface Builder in Xcode ITP 342 Mobile App Dev Interface Builder in Xcode New Project From the Main Menu, select the File à New à Project option For the template, make sure Application is selected under ios on the left-hand side

More information

Announcements. Today s Topics

Announcements. Today s Topics Announcements Lab 2 is due tonight by 11:59 PM Late policy is 10% of lab total per day late So -7.5 points per day late for lab 2 Labs 3 and 4 are posted on the course website Extensible Networking Platform

More information

} override func didreceivememorywarning() { 26 super.didreceivememorywarning() 27 } 28 } Pause Stop

} override func didreceivememorywarning() { 26 super.didreceivememorywarning() 27 } 28 } Pause Stop Chapter 30 30.1 App App MP3 Don t Download This Song [1] Finder MP3 Xcode UI 1 import UIKit 2 import AVFoundation 3 4 class ViewController: UIViewController { 5 6 var player: AVAudioPlayer? 7 8 override

More information

Cocoa Touch Best Practices

Cocoa Touch Best Practices App Frameworks #WWDC15 Cocoa Touch Best Practices Session 231 Luke Hiesterman UIKit Engineer 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission

More information

ITP 342 Mobile App Dev. Delegates

ITP 342 Mobile App Dev. Delegates ITP 342 Mobile App Dev Delegates Protocol A protocol is a declaration of a list of methods Classes that conform to the protocol implement those methods A protocol can declare two kinds of methods: required

More information

ios 9 SDK Development

ios 9 SDK Development Extracted from: ios 9 SDK Development Creating iphone and ipad Apps with Swift This PDF file contains pages extracted from ios 9 SDK Development, published by the Pragmatic Bookshelf. For more information

More information

Covers ios 6. Bear Cahill. Includes 98 Techniques MANNING

Covers ios 6. Bear Cahill. Includes 98 Techniques MANNING Bear Cahill Covers ios 6 Includes 98 Techniques MANNING ios in Practice by Bear Cahill Chapter 5 Copyright 2012 Manning Publications brief contents PART 1 GETTING STARTED...1 1 Getting started with ios

More information

What s New in Core Location

What s New in Core Location Core OS What s New in Core Location Session 706 Stephen Rhee Engineering Manager 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

More information

Advanced Notifications

Advanced Notifications System Frameworks #WWDC16 Advanced Notifications Session 708 Michele Campeotto ios Notifications 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission

More information

Introductory ios Development

Introductory ios Development Introductory ios Development 152-164 Unit 5 - Multi-View Apps Quick Links & Text References What is a Delegate? What is a Protocol? Delegates, Protocols and TableViews Creating a Master-Detail App Modifying

More information

My First iphone App (for Xcode version 6.4)

My First iphone App (for Xcode version 6.4) My First iphone App (for Xcode version 6.4) 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work

More information

Praktikum Entwicklung von Mediensystemen mit

Praktikum Entwicklung von Mediensystemen mit Praktikum Entwicklung von Mediensystemen mit Sommersemester 2013 Fabius Steinberger, Dr. Alexander De Luca Honors Degree in Technology Management at the Center for Digital Technology and Management (Barerstr.

More information

Widget Tour. iphone and ipod touch Development Fall 2009 Lecture 7

Widget Tour. iphone and ipod touch Development Fall 2009 Lecture 7 Widget Tour iphone and ipod touch Development Fall 2009 Lecture 7 Questions? Announcements Assignment #2 due Tonight by 11:59pm Today s Topics Controls Buttons Switches Sliders Segmented Controls Text

More information

Learn to make desktop LE

Learn to make desktop LE HACKING WITH SWIFT COMPLETE TUTORIAL COURSE Learn to make desktop LE P apps with real-worldam S Swift projects REEPaul Hudson F Project 1 Storm Viewer Get started coding in Swift by making an image viewer

More information

Tables. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Tables. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Tables Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Table View Controller Table View Table Cells

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Drag and Drop Transferring information around within and between apps. EmojiArt Demo Drag and drop an image to get our EmojiArt masterpieces started. UITableView

More information

A Mobile Mapping Application

A Mobile Mapping Application A Mobile Mapping Application MANNING SHELTER ISLAND A Mobile Mapping Application A special edition ebook Copyright 2013 Manning Publications contents about mobile mapping about this ebook v about the authors

More information

ADVANCED M A. Learn SiriKit, imessage apps, rich notifications, and more. with real-world projects HACKING WITH SWIFT COMPLETE TUTORIAL COURSE

ADVANCED M A. Learn SiriKit, imessage apps, rich notifications, and more. with real-world projects HACKING WITH SWIFT COMPLETE TUTORIAL COURSE HACKING WITH SWIFT ADVANCED ios VOLUME ONE COMPLETE TUTORIAL COURSE Learn SiriKit, imessage apps, E L P rich notifications, and more M A S with real-world projects E E FR Paul Hudson Chapter 1 Happy Days

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today Core Location Framework for specifying locations on the planet MapKit Graphical toolkit for displaying locations on the planet Core Location

More information

InterfaceBuilder and user interfaces

InterfaceBuilder and user interfaces ES3 Lab 2 InterfaceBuilder and user interfaces This lab InterfaceBuilder Creating components Linking them to your code Adding buttons, labels, sliders UITableView Creating a tableview Customizing cells

More information

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout Overview : Today s Lecture Model View Controller Design Pattern Creating Views in Storyboard Connecting your Views to Code Auto

More information

lecture 10 UI/UX and Programmatic Design cs : spring 2018

lecture 10 UI/UX and Programmatic Design cs : spring 2018 lecture 10 UI/UX and Programmatic Design cs198-001 : spring 2018 1 Announcements custom app progress form due before lab (~1 minute) will be released after lecture only 2 labs left (both very important)

More information

Building GUIs with UIKit. Kevin Cathey

Building GUIs with UIKit. Kevin Cathey Building GUIs with UIKit Kevin Cathey Building GUIs with UIKit acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What is UIKit? acm.uiuc.edu/macwarriors/devphone Building GUIs with UIKit What

More information

Types of Views. View category Purpose Examples of views. Display a particular type of content, such as an image or text.

Types of Views. View category Purpose Examples of views. Display a particular type of content, such as an image or text. ios UI Components Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283 Types of Views View

More information

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Timer Periodically execute a block of code Blinking FaceIt Demo Animation Animating changes to UIViews Smoother Blinking FaceIt Head-shaking FaceIt Animating

More information

let w = UIWindow(frame: UIScreen.mainScreen().bounds)

let w = UIWindow(frame: UIScreen.mainScreen().bounds) PART I Views The things that appear in your app s interface are, ultimately, views. A view is a unit of your app that knows how to draw itself. A view also knows how to sense that the user has touched

More information

MVC & Onwards. CS 442: Mobile App Development Michael Saelee

MVC & Onwards. CS 442: Mobile App Development Michael Saelee MVC & Onwards CS 442: Mobile App Development Michael Saelee Agenda - Recap: view-controller communication - Delegation as a general pattern - Observer pattern - Controller responsibilities & MVC - Multiple

More information

Assignment II: Calculator Brain

Assignment II: Calculator Brain Assignment II: Calculator Brain Objective You will start this assignment by enhancing your Assignment 1 Calculator to include the changes made in lecture (i.e. CalculatorBrain, etc.). This is the last

More information

SWIFT - CLOSURES. Global Functions Nested Functions Closure Expressions. Have a name. Capture values from enclosing function

SWIFT - CLOSURES. Global Functions Nested Functions Closure Expressions. Have a name. Capture values from enclosing function http://www.tutorialspoint.com/swift/swift_closures.htm SWIFT - CLOSURES Copyright tutorialspoint.com Closures in Swift are similar to that of self-contained functions organized as blocks and called anywhere

More information

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc.

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc. Intro to Native ios Development Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (20 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Wunder

More information

HACKING WITH SWIFT. Practical. ios 10 COMPLETE TUTORIAL COURSE. Learn to develop apps. for ios 10 by building MP. real-world projects E S

HACKING WITH SWIFT. Practical. ios 10 COMPLETE TUTORIAL COURSE. Learn to develop apps. for ios 10 by building MP. real-world projects E S HACKING WITH SWIFT Practical ios 10 COMPLETE TUTORIAL COURSE Learn to develop apps E L for ios 10 by building MP A real-world projects E S E FR Paul Hudson Chapter 1 Happy Days www.hackingwithswift.com

More information

News- ipad: ios(swift) Application

News- ipad: ios(swift) Application News- ipad: ios(swift) Application Document Version 1.0.1 Date: 9 th Nov, 2014 2 [NEWS- IPAD: APP DOCUMENTATION] Important Notes:... 6 AppDelegate Class Reference... 7 Tasks... 7 Instance Methods... 7

More information

User Interfaces. Lecture 15. Application Programming on Mac OS. Hamza Bennani September 4, 2018

User Interfaces. Lecture 15. Application Programming on Mac OS. Hamza Bennani September 4, 2018 User Interfaces Lecture 15 Application Programming on Mac OS Hamza Bennani hamza@hamzabennani.com September 4, 2018 Logistics Office hours: Tue/Thu, 2pm to 3pm. Office: 250 Geoff Wyvill. Acknowledgment:

More information

COMPLETE TUTORIAL COURSE. Learn to make tvos LE. apps with real-worldam S F

COMPLETE TUTORIAL COURSE. Learn to make tvos LE. apps with real-worldam S F HACKING WITH SWIFT COMPLETE TUTORIAL COURSE Learn to make tvos LE P apps with real-worldam S Swift projects REEPaul Hudson F Project 1 Randomly Beautiful 2 www.hackingwithswift.com Setting up In this first

More information

Assignment I: Concentration

Assignment I: Concentration Assignment I: Concentration Objective The goal of this assignment is to recreate the demonstration given in lecture and then make some small enhancements. It is important that you understand what you are

More information

CS193P: HelloPoly Walkthrough

CS193P: HelloPoly Walkthrough CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,

More information

Mastering UIKit on tvos

Mastering UIKit on tvos App Frameworks #WWDC16 Mastering UIKit on tvos Session 210 Justin Voss UIKit Engineer 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from

More information

Introduction to WatchKit. CS193W - Spring Lecture 1

Introduction to WatchKit. CS193W - Spring Lecture 1 Introduction to WatchKit CS193W - Spring 2016 - Lecture 1 appleᴡᴀᴛᴄʜ Released April 24, 2015 No updates to the hardware yet. Three collections, over 30 models Two sizes The Screen OLED (organic light-emitting

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today More about Documents Demo Use Codable to create a JSON representation of our document Store it in the filesystem Think better of that and let UIDocument store

More information

COMP327 Mobile Computing Session:

COMP327 Mobile Computing Session: COMP327 Mobile Computing Session: 2018-2019 Lecture Set 5a - + Comments on Lab Work & Assignments [ last updated: 22 October 2018 ] 1 In these Slides... We will cover... Additional Swift 4 features Any

More information

Quick Interaction Techniques for watchos

Quick Interaction Techniques for watchos App Frameworks #WWDC16 Quick Interaction Techniques for watchos Session 211 Tom Witkin watchos Engineer Miguel Sanchez watchos Engineer 2016 Apple Inc. All rights reserved. Redistribution or public display

More information

My First iphone App. 1. Tutorial Overview

My First iphone App. 1. Tutorial Overview My First iphone App 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button. You can type your name

More information

Apple s new Swift language

Apple s new Swift language Microsoft and Apple Training Apple s new Swift language Peter Himschoot peter@u2u.be Agenda Developing for ios overview Xcode, Objective-C, Swift, Development life cycle UI development Interface Builder

More information

Assignment III: Graphing Calculator

Assignment III: Graphing Calculator Assignment III: Graphing Calculator Objective The goal of this assignment is to reuse your CalculatorBrain and CalculatorViewController objects to build a Graphing Calculator for iphone and ipad. By doing

More information

iphone Application Programming Lab 3: Swift Types and Custom Operator + A02 discussion

iphone Application Programming Lab 3: Swift Types and Custom Operator + A02 discussion Lab 3: Swift Types and Custom Operator + A02 discussion Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Learning Objectives Discuss A02 Another implementation

More information

What s New in MapKit. App Frameworks #WWDC17. Fredrik Olsson

What s New in MapKit. App Frameworks #WWDC17. Fredrik Olsson Session App Frameworks #WWDC17 What s New in MapKit 237 Fredrik Olsson 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. MKMapView.mapType.standard

More information

ios Certified Associate Developer (ICAD)

ios Certified Associate Developer (ICAD) TAN DUC INFORMATION TECHNOLOGY SCHOOL JSC Address: 103 Pasteur, Dist.1, HCMC Tel: 08 38245819; 38239761 Email: traincert@tdt-tanduc.com Website: www.tdt-tanduc.com; www.tanducits.com Let s Reach For Excellence!

More information

Writing Energy Efficient Apps

Writing Energy Efficient Apps Session App Frameworks #WWDC17 Writing Energy Efficient Apps 238 Daniel Schucker, Software Power Engineer Prajakta Karandikar, Software Power Engineer 2017 Apple Inc. All rights reserved. Redistribution

More information

ITP 342 Mobile App Dev. Web View

ITP 342 Mobile App Dev. Web View ITP 342 Mobile App Dev Web View Web View 2 WebKit The WebKit provides a set of core classes to display web content in windows, and by default, implements features such as following links clicked by the

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Mostly Swift but some other stuff too Autolayout teaser Quick review of what we learned in Concentration CountableRange of floating point numbers Tuples Computed

More information

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content View Concepts iphone Application Programming Lecture 4: User Interface Design SDK provide many types of Views to show your content At run-time Views are organized as a tree Chat Wacharamanotham Media Computing

More information

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content

View Concepts. iphone Application Programming Lecture 4: User Interface Design. SDK provide many types of Views to show your content View Concepts iphone Application Programming Lecture 4: User Interface Design SDK provide many types of Views to show your content At run-time Views are organized as a tree Chat Wacharamanotham Media Computing

More information

Chapter 2 Welcome App

Chapter 2 Welcome App 2.1 Introduction Chapter 2 Welcome App 1. A app is an app that can run on iphones, ipod touches and ipads. a. multi-purpose b. global c. unrestricted d. universal Ans: d. universal 2. You can your apps

More information