EEC-492/693/793 iPhone Application Development

Slides:



Advertisements
Similar presentations
IOS – Views and Drawing CS4521. Views Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged.
Advertisements

Detecting Collisions CSE 391 Fall 2012 Tony Scarlatos.
Cosc 5/4730 Input Keyboard, touch, and Accelerometer.
Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Other Input Methods Pre-Lab Lecture 4 1. Revisit 2  Pre-Lab 3 – Animation  Boundary Information  Layer Concept  Animation algorithm  Next Position.
Touches Detection and Other Remaining Parts Lecture 3 1.
UIAlertView, UIActionSheet, and Facebook Connection Lecture 4 1.
IPhone 101. Outline Objective-C Random bits of the API Using the simulator Debugging with Xcode.
1 © Wolfgang Pelz UML2 UML Part Two. 2 © Wolfgang Pelz UML2 Chapters Four & Twelve Interaction Diagrams.
XP Tutorial 8 New Perspectives on JavaScript, Comprehensive1 Working with the Event Model Creating a Drag-and-Drop Shopping Cart.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter One An Introduction to Visual Basic 2010.
Using Arrays and File Handling
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
iOS components in Swift
Using Client-Side Scripts to Enhance Web Applications 1.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Multiform Projects.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Using the iPad 9/18/2013. Learning Target I can learn to navigate and use my iPad. Success Criterion: – I can complete at least half of the items on the.
Gestures UIGestureRecognizer.
Where Value and Innovation Co-exist Gestures and User Interaction Best Practices.
User Interface Objects From Beginning iPhone 4 Development and The iPhone Developer’s Cookbook (Chapter 4)
Splatter! ALPHA Presentation By: David Kikuta March 29, 2011.
Splatter! Critical Design Review By: David Kikuta March 15, 2011.
Twist, Touch & Travel Touch, Twist, and Travel Harnessing the iPhone's Unique Features Glenda Adams Maverick Software
Using the iPad 8/14/2013. Learning Target I can learn to navigate and use my iPad. Success Criterion: – I can complete at least half of the items on the.
1 Reverse a String iPhone/iPad, iOS Development Tutorial.
2/20/2016 EEC492/693/793 - iPhone Application Development 12/20/2016 EEC492/693/793 - iPhone Application Development 1 EEC-492/693/793 iPhone Application.
Mindstorm NXT-G Introduction Towson University Robotics.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
JQuery Events, Mobile Events, and Page Events CIS 136 Building Mobile Apps 1.
CHAPTER 7 TouchGestures. Chapter objectives: To code the detection of and response to touch gestures. Patterns of common touches to create touch gestures.
이미지 뷰의 애니메이션 이미지 뷰는 자체적으로 애니메이션 기능을 제공하고 있습니다.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Touch and Go: Leading Touch UI with Open Source
IOS Design Patterns Sisoft Technologies Pvt Ltd
Fluency with Information Technology
iOS UI Components Sisoft Technologies Pvt Ltd
iOS - First Application Anatomy
View-Controller Family
Objectives To define terminology associated with Windows operating systems. To examine uses of Windows in business and industry. To explain techniques.
Objectives To review concepts covered in the Windows Operating Systems units.
IOS App Development.
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Program and Graphical User Interface Design
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Introduction to pseudocode
CIS16 Application Development Programming with Visual Basic
Working with the Event Model
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Exception Handling Chapter 9 Edited by JJ.
CSC 581: Mobile App Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Development with UIKit on Xamarin.ios
EEC-492/693/793 iPhone Application Development
Presentation transcript:

EEC-492/693/793 iPhone Application Development Lecture 16 Wenbing Zhao & Nigamanth Sridhar 2/22/2019 EEC492/693/793 - iPhone Application Development

Outline Taps, touches and gestures Assignment: Terminology UITouch UIEvent UIResponder Apps in chapter 13 Assignment: Build the set of apps in chapter 13 2/22/2019 2/22/2019 EEC492/693/793 - iPhone Application Development EEC492/693/793 - iPhone Application Development 2

Taps, Touches and Gestures Gesture: any sequence of events that happens from the time you touch the screen with one or more fingers until you lift your figures off the screen Touch: refers to a finger being placed on the screen One finger, one touch Tap: you touch the screen with a single finger and then immediately lift your finger off the screen without moving it around 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development The Responder Chain Events get passed through the responder chain First responder: usually the object with which the user is currently interacting If a responder in the chain doesn’t handle a particular event, it passes that event up the responder chain Application Window UIApplication View View Controller superview View View Controller superview View View Controller View hierarchy Event 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development UITouch Represents a single finger @property(nonatomic,readonly) NSTimeInterval timestamp; // indicates whether the touch began, moved, ended, or was canceled @property(nonatomic,readonly) UITouchPhase phase; @property(nonatomic,readonly) NSUInteger tapCount; @property(nonatomic,readonly,retain) UIWindow *window; @property(nonatomic,readonly,retain) UIView *view; // The view in which the touch initially occurred - (CGPoint)locationInView:(UIView *)view; - (CGPoint)previousLocationInView:(UIView *)view; Timestamp: The value of this property is the time, in seconds, since system startup the touch either originated or was last changed. You can store and compare the initial value of this attribute to subsequent timestamp values of the UITouch instance to determine the duration of the touch and, if it is being swiped, the speed of movement. Phase: The property value is a constant that indicates whether the touch began, moved, ended, or was canceled. For descriptions of possible UITouchPhase values, see “Touch Phase.” tapCount: The value of this property is an integer indicating the number of times the user tapped their fingers on a certain point within a predefined period. 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development UIEvent A container for one or more touches @property(nonatomic,readonly) NSTimeInterval timestamp; - (NSSet *)allTouches; - (NSSet *)touchesForWindow:(UIWindow *)window; - (NSSet *)touchesForView:(UIView *)view; 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development UIEvent - (NSSet *)allTouches; UIEvent UITouch Window A Window B View A View B View C 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development UIEvent - (NSSet *)touchesForWindow:(UIWindow *)window; UIEvent UITouch Window A Window B View A View B View C 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development UIEvent - (NSSet *)touchesForView:(UIView *)view; UIEvent UITouch Window A Window B View A View B View C 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development Receiving Touches UIResponder - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development UIResponder NSObject UIResponder UIApplication UIView UIViewController UIImageView UILabel UIControl UIControl UIScrollView UIButton UISlider UISwitch UITextField 2/22/2019 EEC492/693/793 - iPhone Application Development

Single & Multiple Touch Sequence Show Stanford Slides 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development The Touch Explore App - (void)updateLabelsFromTouches:(NSSet *)touches { NSUInteger numTaps = [[touches anyObject] tapCount]; NSString *tapsMessage = [[NSString alloc] initWithFormat:@"%d taps detected", numTaps]; tapsLabel.text = tapsMessage; [tapsMessage release]; NSUInteger numTouches = [touches count]; NSString *touchMsg = [[NSString alloc] initWithFormat: @"%d touches detected", numTouches]; touchesLabel.text = touchMsg; [touchMsg release]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { messageLabel.text = @"Touches Began"; [self updateLabelsFromTouches:touches]; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {…} - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {…} - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{…} 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development The Swipes App - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; gestureStartPoint = [touch locationInView:self.view]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint currentPosition = [touch locationInView:self.view]; CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x); CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y); if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance) { label.text = @"Horizontal swipe detected"; [self performSelector:@selector(eraseText) withObject:nil afterDelay:2]; else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){ label.text = @"Vertical swipe detected"; [self performSelector:@selector(eraseText) withObject:nil afterDelay:2]; 2/22/2019 EEC492/693/793 - iPhone Application Development

The Swipes App: Detect Multiple Swipes When touchesBegan:withEvent: gets notified that a gesture has begun, we save one finger’s position When we check for swipes, we loop through all the touches provided to the touchesMoved:withEvent: method, comparing each one to the saved point If the user did a multiple-finger swipe, when comparing to the saved point, at least one of the touches we get in that method will indicate a swipe If we find either a horizontal or vertical swipe, we loop through the touches again and make sure that every finger is at least the minimum distance away from the first finger’s horizontal or vertical position, depending on the type of swipe 2/22/2019 EEC492/693/793 - iPhone Application Development

The TapTaps App: Detecting Multiple Taps If the user did a triple tap, there will be three separate notifications: Single tap Double tap Triple tap How can we handle the triple tap properly? [self performSelector:@selector(singleTap) withObject:nil afterDelay:.4]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTap) object:nil]; 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development The PinchMe App - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if ([touches count] == 2) { NSArray *twoTouches = [touches allObjects]; UITouch *first = [twoTouches objectAtIndex:0]; UITouch *second = [twoTouches objectAtIndex:1]; CGFloat currentDistance = distanceBetweenPoints( [first locationInView:self.view], [second locationInView:self.view]); if (initialDistance == 0) initialDistance = currentDistance; else if (currentDistance - initialDistance > kMinimumPinchDelta) { label.text = @"Outward Pinch"; [self performSelector:@selector(eraseLabel) withObject:nil afterDelay:1.6f]; } else if (initialDistance - currentDistance > kMinimumPinchDelta) { label.text = @"Inward Pinch"; You need CGPointUtils.h and CGPointUtils.c 2/22/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development The CheckPlease App - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint previousPoint = [touch previousLocationInView:self.view]; CGPoint currentPoint = [touch locationInView:self.view]; CGFloat angle = angleBetweenLines(lastPreviousPoint, lastCurrentPoint, previousPoint, currentPoint); if (angle >= kMinimumCheckMarkAngle&& angle <= kMaximumCheckMarkAngle && lineLengthSoFar > kMinimumCheckMarkLength) { label.text = @"Checkmark"; [self performSelector:@selector(eraseLabel) withObject:nil afterDelay:1.6]; } lineLengthSoFar += distanceBetweenPoints(previousPoint, currentPoint); lastPreviousPoint = previousPoint; lastCurrentPoint = currentPoint; You need CGPointUtils.h and CGPointUtils.c 2/22/2019 EEC492/693/793 - iPhone Application Development