再UIView中,可以重些以下四个方法来来控制用户的触摸动作:
- - (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;
[touch phase] 就可以获知触摸的方式,它是一个枚举类型来的.
typedef enum {
UITouchPhaseBegan, // whenever a finger touches the surface.
UITouchPhaseMoved, // whenever a finger moves on the surface.
UITouchPhaseStationary, // whenever a finger is touching the surface but hasn't moved since the previous event.
UITouchPhaseEnded, // whenever a finger leaves the surface.
UITouchPhaseCancelled, // whenever a touch doesn't end but we need to stop tracking (e.g. putting device to face)
} UITouchPhase;
touch tapCount 可以获取这个触摸的点击次数.(类似双击鼠标,如果双击就是2次)
touch timestamp 获取触摸的时间戳,这样可以计算一些点击的频率等应用.
touch locationInView: 获取坐标系,在某个view中
touch previousLocationInView: 获取在某个view中的前一次坐标系
touch gestureRecognizers 这个3.2新增加的(iPad),用于判断手势用
新增加的手势判断有以下这几种:
- UILongPressGestureRecognizer
- UIPanGestureRecognizer
- UIPinchGestureRecognizer
- UIRotationGestureRecognizer
- UISwipeGestureRecognizer
- UITapGestureRecognizer