UI Design and Storyboarding

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

Mobile Development - Lab 2

Miscellaneous Topics

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

ITP 342 Mobile App Dev. Connections

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

Lecture 8 Demo Code: Cassini Multithreading

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.

ios Development - Xcode IDE

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

Document Version Date: 1st March, 2015

Mobile Development Lab 3

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

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

ITP 342 Mobile App Dev. Connections

Building Mapping Apps for ios With Swift

Navigation and Segues

Step 1: Open Xcode and select Create a new Xcode Project from the Welcome to Xcode menu.

Introductory ios Development

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

Social Pinboard: ios(swift) Application

Building the App - Part 5 - Adding a Link

Collection Views. Dr. Sarah Abraham

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

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

Announcements. Today s Topics

Implementing UI Designs in Interface Builder

IOS - TEXT FIELD. Use of Text Field. Important Properties of Text Field. Updating Properties in xib

Chapter 22 TableView TableView. TableView ios. ViewController. Cell TableViewCell TableView

Rx in the real world. 1 Rob Ciolli

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

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

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

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

Mobile Applications Development. Swift, Cocoa and Xcode

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

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

Apple Watch Docs. Release 0.1. Michael Hahn

ITP 342 Mobile App Dev. Interface Builder in Xcode

Mastering UIKit on tvos

ios Core Data Example Application

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

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

Stream iphone Sensor Data to Adafruit IO

Building Faster in Xcode

Assignment II: Calculator Brain

Xcode 4 Cookbook. Steven F. Daniel. Chapter No. 2 "User Interfaces Creating the UI"

iphone Application Tutorial

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

AVAudioPlayer. avtouch Application

Enhancing your apps for the next dimension of touch

Your First iphone Application

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

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

InterfaceBuilder and user interfaces

ITP 342 Mobile App Dev. Fundamentals

CSC 581: Mobile App Development Spring 2019

ios 9 SDK Development

ITP 342 Mobile App Dev. Delegates

CS193P - Lecture 11. iphone Application Development. Text Input Presenting Content Modally

src3/bettertextfield/bettertextfield/appdelegate.h // AppDelegate.h // BetterTextField

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

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

Advanced Notifications

Cocoa Touch Best Practices

Announcements. Paparazzi 3 assignment is due Wednesday 2/17 This Friday s extra session will feature Evan Doll

COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2

ITP 342 Mobile App Dev. Table Views

Working with Text, Keyboards, and Buttons

Learn to make desktop LE

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

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

My First iphone App (for Xcode version 6.4)

lectures/2/src2/nib1/nib1/appdelegate.h // AppDelegate.h // Nib1 // David J. Malan // Harvard University //

Building GUIs with UIKit. Kevin Cathey

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

CS193P - Lecture 11. iphone Application Development. Text Input Presenting Content Modally

Your First iphone OS Application

Lecture 5 Demo Code: FaceIt MVC and Gestures

ITP 342 Mobile App Dev. Web View

ios Application Development Hello World App Rubric

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

ios Application Development Course Details

CS 160: Interactive Programming

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

User Interfaces. Lecture 16. Model - View - Controller. Hamza Bennani September 6, 2018

Learn to make watchosle

ios Application Development Lecture 5: Protocols, Extensions,TabBar an Scroll Views

Graphics and Animation

imate: ios Application

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

ITP 342 Mobile App Dev. Animation

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

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

Topics in Mobile Computing

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

News- ipad: ios(swift) Application

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

ios Tic Tac Toe Game John Robinson at Rowan University

Timers Timer CPRE 388

Transcription:

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 (MVC) design Storyboarding Delegates Multi-threading Mobile Application Development in ios 2

Model-View-Controller (MVC) class ViewController { IBAction IBOutlet Delegate Data Storyboard class Model { var value: Int Mobile Application Development in ios 3

Model protocol MyTimerDelegate { func timechanged (time: Int) func timesup (message: String) class MyTimer { var initialtime: Int var currenttime: Int var message: String var running: Bool var delegate: MyTimerDelegate? init (initialtime: Int, message: String) { self.initialtime = initialtime self.currenttime = initialtime self.message = message self.running = false Mobile Application Development in ios 4

Model func start () { running = true func stop () { running = false func reset () { currenttime = initialtime delegate?.timechanged(time: currenttime) func decrement () { if running { currenttime -= 1 delegate?.timechanged(time: currenttime) if currenttime == 0 { running = false delegate?.timesup(message: self.message) Mobile Application Development in ios 5

Storyboard Mobile Application Development in ios 6

Storyboard: Adding Elements 1. Drag element into view. 2. Add layout contraints. 3. Connect element to view controller. Adding elements to views Create IBOutlet to get/set properties of element Create IBAction to detect interaction with element Mobile Application Development in ios 7

Delegate Object that responds to events from another object Defines a protocol that must be followed View elements generating multiple different actions use delegates (rather than IBAction) E.g., UITextField Mobile Application Development in ios 8

Delegate Example: UITextField UITextFieldDelegate textfielddidbeginediting textfielddidendediting textfieldshouldreturn More developer.apple.com/documentation/uikit/uitextfielddelegate Mobile Application Development in ios 9

UITextField Delegate class ViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var messagetext: UITextField! func textfielddidendediting(_ textfield: UITextField) { mytimer.message = textfield.text! func textfieldshouldreturn(_ textfield: UITextField) -> Bool { textfield.resignfirstresponder() // remove keyboard on Return return false // do default behavior (i.e., nothing)? No override func viewdidload() { super.viewdidload() messagetext.delegate = self Mobile Application Development in ios 10

Multi-Threading Running multiple tasks concurrently Tasks assigned to threads Threads assigned to processor cores Neural Processing Unit A9: 2 cores, iphone 6 A10: 4 cores, iphone 7 A11: 6 cores, iphone 8/X Mobile Application Development in ios 11

Multi-Threading in ios Manipulate queues, not threads Grand Central Dispatch (GCD) let myqueue = DispatchQueue.global() myqueue.async { // Do something, not affecting UI ios mechanism for sending tasks to different queues You can create your own queues, and assign tasks to them Threads take tasks from queues and run on a core Main queue used for UI and user interaction Don t put intensive tasks on Main queue! Also, UI changes not on Main queue lost DispatchQueue.main.async { // Do something easy // Or affecting UI Mobile Application Development in ios 12

Timers Timer class Wait specified time interval, then call function Can repeat Start immediately scheduledtimer(withtimeinterval interval: TimeInterval, repeats: Bool, block: @escaping (Timer) -> Void) -> Timer Stop Timer.invalidate() Mobile Application Development in ios 13

Timers Create init(timeinterval interval: TimeInterval, repeats: Bool, block: @escaping (Timer) -> Void) -> Timer Create to fire later init(fire: Date, timeinterval interval: TimeInterval, repeats: Bool, block: @escaping (Timer) -> Void) -> Timer Add to run loop let runloop = RunLoop.current runloop.add(timer, formode:.defaultrunloopmode) Mobile Application Development in ios 14

Timers var internaltimer: Timer? func startbuttontapped { // Start immediately internaltimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: handletick) // Or, initialize then add to run loop internaltimer = Timer.init(withTimeInterval: 1.0, repeats: true, block: handletick) RunLoop.current.add(internalTimer!, formode:.defaultrunloopmode) func timesup (message: String) { internaltimer?.invalidate() messagelabel.text = message func handletick (timer: Timer) { print("tick") Mobile Application Development in ios 15

Resources Storyboard https://www.raywenderlich.com/160521/storyboards-tutorial-ios-11-part-1 Protocols and Delegates https://developer.apple.com/library/content/documentation/swift/conceptual/swift_progra mming_language/protocols.html UITextField and UITextFieldDelegate https://developer.apple.com/documentation/uikit/uitextfield https://developer.apple.com/documentation/uikit/uitextfielddelegate Grand Central Dispatch (GCD) Timer https://developer.apple.com/documentation/dispatch https://developer.apple.com/documentation/foundation/timer Mobile Application Development in ios 16