部分内容摘自:http://www.cnblogs.com/kenshincui/p/3950646.html
触摸事件 | |
- (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; | 触摸意外取消时执行(例如正在触摸时打入电话); |
在事件处理函数中从touches(NSSet*)中获得UITouch对象,通过该对象来获得触摸时相应的状态参数等,常用的方法及属性有:
1. - (CGPoint)locationInView:(UIView *)view
Returns the current location of the receiver in the coordinate system of the given view.
返回“当前触点”在给定视图中的坐标
2. - (CGPoint)previousLocationInView:(UIView *)view
Returns the previous location of the receiver in the coordinate system of the given view.
返回“上一个触点”在给定视图中的坐标
3.@property(nonatomic, readonly, retain) UIView *view
The view in which the touch initially occurred. (read-only)
发生触发的视图(只读)
4.@property(nonatomic, readonly, retain) UIWindow *window
The
window in which the touch initially occurred. (read-only)
发生触发的窗口(只读)
5.@property(nonatomic, readonly) NSUInteger tapCount
The
number of times the finger was tapped for this given touch. (read-only)
点击次数(只读)短期内
6.@property(nonatomic, readonly) NSTimeInterval timestamp
The
time when the touch occurred or when it was last mutated. (read-only)
触摸产生或变化的时间戳(只读)
7.对UIEvent对象:
- (NSSet *)touchesForView:(UIView *)view
Returns the touch objects that belong to a given view for the event represented by the receiver.
返回位于给定的视图的触摸集合。