码迷,mamicode.com
首页 > 其他好文 > 详细

Chapter 12 Touch Events and UIResponder

时间:2014-09-23 01:12:03      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:io   os   ar   for   sp   art   on   c   ef   

Chapter 12  Touch Events and UIResponder

 

1.As a subclass of UIResponder, a UIView can override four methods to handle the distinct touch events:

a finger or fingers touches the screen:

-(void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event

a finger or fingers moves across the screen (this message is sent repeatedly as a finger moves)

-(void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event

a finger or fingers is removed from the screen

-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event

a system event, like an incoming phone call, interrupts a touch before it ends

-(void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event;

 

2. When a finger touches the screen, an instance of UITouch is created. The UIView that this finger touched is sent the message touchesBegan:withEvent: and the UITouch is in the NSSet of touches.

 

3. How touch objects work:

One UITouch corresponds to one finger on the screen. This touch object lives as long as the finger is on the screen and always contains the current position of the finger on the screen.

The view that the finger started on will receive every touch event message of that finger no matter what. If the finger moves outside of the UIView’s frame that it began on, that view still receives the touchesMoved:withEvent: and touchesEnded:withEvent: messages. Thus, if a touch begins on a view, then that view owns the touch for the life of the touch.

You do not have to - nor should you ever - keep a reference to a UITouch object. The application will give you access to a touch object when it changes state.

 

 

 

 

 

 

Chapter 12 Touch Events and UIResponder

标签:io   os   ar   for   sp   art   on   c   ef   

原文地址:http://www.cnblogs.com/1oo1/p/3987183.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!