Cs 193p 15 Multitouch

  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Cs 193p 15 Multitouch as PDF for free.

More details

  • Words: 2,186
  • Pages: 139
CS193P - Lecture 15 iPhone Application Development Multi-Touch Events

Friday, November 14, 2008

1

Announcements

Friday, November 14, 2008

2

Announcements • Problems with developer program activation codes

Friday, November 14, 2008

2

Announcements • Problems with developer program activation codes • Guest lecturers on Friday App Store developers ■ How to publish apps on the app store ■ Friday 11/14, Hewlett Teaching Center 201, 4:00 PM ■

Friday, November 14, 2008

2

Friday, November 14, 2008

3

Friday, November 14, 2008

4

Friday, November 14, 2008

4

Friday, November 14, 2008

4

Friday, November 14, 2008

4

Today’s Topics

Friday, November 14, 2008

5

Today’s Topics • Touch Sequences • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

5

Today’s Topics • Touch Sequences • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

6

Single Touch Sequence

Friday, November 14, 2008

7

Single Touch Sequence

Friday, November 14, 2008

7

Single Touch Sequence

Friday, November 14, 2008

7

Single Touch Sequence

Friday, November 14, 2008

7

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

8

UITouch

Friday, November 14, 2008

9

UITouch Represents a single finger

Friday, November 14, 2008

9

UITouch Represents a single finger @property(nonatomic,readonly) NSTimeInterval @property(nonatomic,readonly) UITouchPhase @property(nonatomic,readonly) NSUInteger

Friday, November 14, 2008

timestamp; phase; tapCount;

9

UITouch Represents a single finger @property(nonatomic,readonly) NSTimeInterval @property(nonatomic,readonly) UITouchPhase @property(nonatomic,readonly) NSUInteger @property(nonatomic,readonly,retain) UIWindow @property(nonatomic,readonly,retain) UIView

Friday, November 14, 2008

timestamp; phase; tapCount; *window; *view;

9

UITouch Represents a single finger @property(nonatomic,readonly) NSTimeInterval @property(nonatomic,readonly) UITouchPhase @property(nonatomic,readonly) NSUInteger @property(nonatomic,readonly,retain) UIWindow @property(nonatomic,readonly,retain) UIView

timestamp; phase; tapCount; *window; *view;

- (CGPoint)locationInView:(UIView *)view; - (CGPoint)previousLocationInView:(UIView *)view;

Friday, November 14, 2008

9

UIEvent

Friday, November 14, 2008

10

UIEvent A container for one or more touches

Friday, November 14, 2008

10

UIEvent A container for one or more touches @property(nonatomic,readonly) NSTimeInterval timestamp;

Friday, November 14, 2008

10

UIEvent A container for one or more touches @property(nonatomic,readonly) NSTimeInterval timestamp; - (NSSet *)allTouches; - (NSSet *)touchesForWindow:(UIWindow *)window; - (NSSet *)touchesForView:(UIView *)view;

Friday, November 14, 2008

10

UIEvent

Friday, November 14, 2008

11

UIEvent UIEvent

Friday, November 14, 2008

11

UIEvent UIEvent

UITouch

UITouch

UITouch

UITouch

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

UITouch

UITouch

UITouch

Friday, November 14, 2008

Window B

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

Friday, November 14, 2008

View B

Window B View C

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)allTouches;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)allTouches;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForWindow:(UIWindow *)window;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForWindow:(UIWindow *)window;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForWindow:(UIWindow *)window;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForView:(UIView *)view;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForView:(UIView *)view;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForView:(UIView *)view;

Friday, November 14, 2008

11

UIEvent Window A UIEvent

UITouch

View A

UITouch

UITouch

UITouch

View B

Window B View C

- (NSSet *)touchesForView:(UIView *)view;

Friday, November 14, 2008

11

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

12

Receiving Touches

Friday, November 14, 2008

13

Receiving Touches UIResponder

Friday, November 14, 2008

13

Receiving Touches UIResponder - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

Friday, November 14, 2008

13

Receiving Touches UIResponder - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

Friday, November 14, 2008

13

Receiving Touches UIResponder - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

Friday, November 14, 2008

13

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;

Friday, November 14, 2008

13

UIResponder

Friday, November 14, 2008

14

UIResponder NSObject

UIResponder

Friday, November 14, 2008

14

UIResponder NSObject

UIResponder

UIApplication

Friday, November 14, 2008

UIView

UIViewController

14

UIResponder NSObject

UIResponder

UIApplication

UIView

UIViewController

UILabel

UIControl

UIWindow

UIImageView

UIButton

Friday, November 14, 2008

UISlider

UISwitch

UIScrollView

UITextField

14

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

15

Single Touch Sequence

Friday, November 14, 2008

16

Single Touch Sequence UITouch 0x123 Phase: Began Location: 160, 120

touchesBegan:withEvent:

Friday, November 14, 2008

16

Single Touch Sequence UITouch 0x123 Phase: Moved Began Location: 160, 160 120

touchesMoved:withEvent:

Friday, November 14, 2008

16

Single Touch Sequence UITouch 0x123 Phase: Moved Began Location: 160, 200 120 160

touchesMoved:withEvent:

Friday, November 14, 2008

16

Single Touch Sequence UITouch 0x123 Phase: Moved Began Location: 160, 240 120 160 200

touchesMoved:withEvent:

Friday, November 14, 2008

16

Single Touch Sequence UITouch 0x123 Phase: Ended Began Moved Location: 160, 240 120 160 200

touchesEnded:withEvent:

Friday, November 14, 2008

16

Single Touch Demo

Friday, November 14, 2008

17

Single Touch Demo

Friday, November 14, 2008

17

Demo Single Touch

Friday, November 14, 2008

18

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

19

Multiple Touches

Friday, November 14, 2008

20

Multiple Touches UIView Property BOOL multipleTouchEnabled;

Friday, November 14, 2008

20

Multiple Touch Sequence

Friday, November 14, 2008

21

Multiple Touch Sequence UITouch 0x123 Phase: Began Location: 120, 200

touchesBegan:withEvent:

Friday, November 14, 2008

21

Multiple Touch Sequence UITouch 0x123 Phase: Moved Location: 120, 240

touchesMoved:withEvent:

Friday, November 14, 2008

21

Multiple Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Stationary Location: 120, 240

Phase: Began Location: 200, 200

touchesBegan:withEvent:

Friday, November 14, 2008

21

Multiple Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Moved Location: 120, 280

Phase: Moved Location: 200, 240

touchesMoved:withEvent:

Friday, November 14, 2008

21

Multiple Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Stationary Location: 120, 280

Phase: Moved Location: 200, 280

touchesMoved:withEvent:

Friday, November 14, 2008

21

Multiple Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Ended Location: 120, 280

Phase: Ended Location: 200, 280

touchesEnded:withEvent:

Friday, November 14, 2008

21

Multiple Touches Demo

Friday, November 14, 2008

22

Multiple Touches Demo

Friday, November 14, 2008

22

Demo Multiple Touches

Friday, November 14, 2008

23

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

24

Multiple Views Touch Sequence

Friday, November 14, 2008

25

Multiple Views Touch Sequence UITouch 0x123 Phase: Began Location: 120, 200

touchesBegan: withEvent: Friday, November 14, 2008

25

Multiple Views Touch Sequence UITouch 0x123 Phase: Moved Location: 120, 240

touchesMoved: withEvent: Friday, November 14, 2008

25

Multiple Views Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Stationary Location: 120, 240

Phase: Began Location: 200, 200

touchesBegan: withEvent: Friday, November 14, 2008

25

Multiple Views Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Moved Location: 120, 280

Phase: Moved Location: 200, 240

touchesMoved: touchesMoved: withEvent: withEvent: Friday, November 14, 2008

25

Multiple Views Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Stationary Location: 120, 280

Phase: Moved Location: 200, 280

touchesMoved: withEvent: Friday, November 14, 2008

25

Multiple Views Touch Sequence UITouch 0x123

UITouch 0xabc

Phase: Ended Location: 120, 280

Phase: Ended Location: 200, 280

touchesEnded: touchesEnded: withEvent: withEvent: Friday, November 14, 2008

25

Multiple Views

Friday, November 14, 2008

26

Multiple Views UIView Property BOOL exclusiveTouch;

Friday, November 14, 2008

26

Multiple Views Demo

Friday, November 14, 2008

27

Multiple Views Demo

Friday, November 14, 2008

27

Demo Multiple Views

Friday, November 14, 2008

28

Demo Multiple Views

developer.apple.com/wwdc/attendee

Friday, November 14, 2008

29

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

30

Responder Chain UIView

Friday, November 14, 2008

31

Responder Chain UIView

Friday, November 14, 2008

UIViewController

31

Responder Chain UIView

UIViewController

superview UIView

Friday, November 14, 2008

31

Responder Chain UIView

UIViewController

superview UIView

Friday, November 14, 2008

UIViewController

31

Responder Chain UIView

UIViewController

superview UIView

UIViewController

superview UIView

Friday, November 14, 2008

31

Responder Chain UIView

UIViewController

superview UIView

UIViewController

superview UIView

Friday, November 14, 2008

UIViewController

31

Responder Chain UIView

UIViewController

superview UIView

UIViewController

superview UIView

UIViewController

window UIWindow

Friday, November 14, 2008

31

Responder Chain UIView

UIViewController

superview UIView

UIViewController

superview UIView

UIViewController

window UIWindow

Friday, November 14, 2008

UIApplication

31

Responder Chain UIView superview UIView superview UIView

UIViewController

window UIWindow

Friday, November 14, 2008

UIApplication

31

Hit Testing Window View Subview

Friday, November 14, 2008

32

Hit Testing Window View Subview

Friday, November 14, 2008

32

Hit Testing Window View Subview

hitTest:withEvent:

Friday, November 14, 2008

32

Hit Testing Window View Subview

hitTest:withEvent:

• userInteractionEnabled

Friday, November 14, 2008

32

Hit Testing Window View Subview

hitTest:withEvent:

• userInteractionEnabled • hidden/alpha

Friday, November 14, 2008

32

Hit Testing Window View Subview

hitTest:withEvent:

• userInteractionEnabled • hidden/alpha • pointInside:withEvent:

Friday, November 14, 2008

32

Hit Testing Window View Subview

hitTest:withEvent:

• userInteractionEnabled • hidden/alpha • pointInside:withEvent:

Friday, November 14, 2008

32

Hit Testing Window View Subview

UITouch view window

Friday, November 14, 2008

32

Hit Testing Window ScrollView Subview

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

hitTest:withEvent:

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

hitTest:withEvent:

• userInteractionEnabled

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

hitTest:withEvent:

• userInteractionEnabled • hidden/alpha

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

hitTest:withEvent:

• userInteractionEnabled • hidden/alpha • pointInside:withEvent:

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

UITouch view window

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

hitTest:withEvent:

UITouch view window

Friday, November 14, 2008

33

Hit Testing Window ScrollView Subview

UITouch view window - (NSSet *)touchesForView:(UIView *)view;

Friday, November 14, 2008

33

Today’s Topics • Touch Sequences and Phases • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

34

UIControlEvents

Friday, November 14, 2008

35

UIControlEvents UIControlEventTouchDown UIControlEventTouchDownRepeat

Friday, November 14, 2008

35

UIControlEvents UIControlEventTouchDown UIControlEventTouchDownRepeat UIControlEventTouchDragInside UIControlEventTouchDragOutside

Friday, November 14, 2008

35

UIControlEvents UIControlEventTouchDown UIControlEventTouchDownRepeat UIControlEventTouchDragInside UIControlEventTouchDragOutside UIControlEventTouchDragEnter UIControlEventTouchDragExit

Friday, November 14, 2008

35

UIControlEvents UIControlEventTouchDown UIControlEventTouchDownRepeat UIControlEventTouchDragInside UIControlEventTouchDragOutside UIControlEventTouchDragEnter UIControlEventTouchDragExit UIControlEventTouchUpInside UIControlEventTouchUpOutside

Friday, November 14, 2008

35

UIControlEvents UIControlEventTouchDown UIControlEventTouchDownRepeat UIControlEventTouchDragInside UIControlEventTouchDragOutside UIControlEventTouchDragEnter UIControlEventTouchDragExit UIControlEventTouchUpInside UIControlEventTouchUpOutside UIControlEventTouchCancel

Friday, November 14, 2008

35

Associating actions with UIControlEvents

Friday, November 14, 2008

36

Associating actions with UIControlEvents - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

Friday, November 14, 2008

36

Associating actions with UIControlEvents - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

Action Signatures

Friday, November 14, 2008

36

Associating actions with UIControlEvents - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

Action Signatures - (void)performAction;

Friday, November 14, 2008

36

Associating actions with UIControlEvents - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

Action Signatures - (void)performAction; - (void)performAction:(id)sender;

Friday, November 14, 2008

36

Associating actions with UIControlEvents - (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

Action Signatures - (void)performAction; - (void)performAction:(id)sender; - (void)performAction:(id)sender withEvent:(UIEvent *)event;

Friday, November 14, 2008

36

UIControl Touch Tracking

Friday, November 14, 2008

37

UIControl Touch Tracking - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;

Friday, November 14, 2008

37

UIControl Touch Tracking - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event; - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;

Friday, November 14, 2008

37

UIControl Touch Tracking - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event; - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event; - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event;

Friday, November 14, 2008

37

UIControl Touch Tracking - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event; - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event; - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event; - (void)cancelTrackingWithEvent:(UIEvent *)event;

Friday, November 14, 2008

37

UIControl Demo

Friday, November 14, 2008

38

Demo UIControl

Friday, November 14, 2008

39

Summary

Friday, November 14, 2008

40

Summary • Touch Sequences • Touch and Event Objects • Touch Delivery • Single Touch • Multiple Touches • Multiple Views • Touch Routing • UIControl Objects

Friday, November 14, 2008

40

Questions?

Friday, November 14, 2008

41

Related Documents

Cs 193p 15 Multitouch
April 2020 2
Cs 15
October 2019 5
Standford Cs 193p: 10-data
November 2019 19