--------------------------------------------------<UIRenponder>-------------------------------------------------------
- (UIResponder*)nextResponder;
响应对象链,指向下一响应对象。
view->viewController->UIWindows->UIApplication->AppDelegate
响应链工作方式:view如果实现了那几个touch方法。则代表view已经处理了事件,便不会把事件往上传递。如果没有实现touch方法,则把事件交给nextResponder所指的对象响应(即执行该对象对应的touch方法),也可以在touch方法里加入语句[super touchesBeganXXX]实现相同功能。
- (BOOL)canBecomeFirstResponder; // default is NO
如果希望视图成为 第一响应对象,实现该方法,并返回YES
- (BOOL)becomeFirstResponder;
判断视图是否可以成为第一响应对象。
- (BOOL)canResignFirstResponder; // default is YES
是否可以取消第一响应对象状态,大多时候返回yes,文本框返回no不能关闭键盘。
- (BOOL)resignFirstResponder;
判断对象可否取消第一响应对象状态。
- (BOOL)isFirstResponder;
可以判断视图现在是否是第一响应对象
- (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;
事件被打断时调用此方法(如来电话)
ps:经测试,第一个参数touches和第二个参数的[event allTouches]总是相等。
多点触控下,一般把UITouch的地址做散列,生成NSVlue对象,以区别不同的点。
------------------------------------------------------<UIEvent>-------------------------------------------------------
@property(nonatomic,readonly) UIEventType type NS_AVAILABLE_IOS(3_0);
事件类型,ios总共接受三种事件,在UIEventType枚举里定义,分别为:
UIEventTypeTouches 触摸
UIEventTypeMotion 移动(设备)
UIEventTypeRemoteControl 远程控制(没用过,估计是外部设备子类的吧)
@property(nonatomic,readonly) UIEventSubtype subtype NS_AVAILABLE_IOS(3_0);
事件子类型,扩充了远程控制的类型。
touch事件还是万年不变的0
@property(nonatomic,readonly) NSTimeInterval timestamp;
时间戳。
- (NSSet *)allTouches;
其实返回的就是UITouch。几点触控,就返回几个UITouch。
- (NSSet *)touchesForWindow:(UIWindow *)window;
返回windows下的touch集合。不过ios程序大部分只有一个UIwindows对象。
- (NSSet *)touchesForView:(UIView *)view;
获取指定视图(参数view)上的touch集合。
例如,一个控制器上有两个视图,且这两个视图都不自己处理touch事件。在控制器可以通过该方法知道当前touch在哪个视图上。
- (NSSet *)touchesForGestureRecognizer:(UIGestureRecognizer *)gesture NS_AVAILABLE_IOS(3_2);
获取指定手势的touch集合
--------------------------------------------------------------<UITouch>------------------------------------
@property(nonatomic,readonly) NSTimeInterval timestamp;
时间戳
@property(nonatomic,readonly) UITouchPhase phase;
阶段,开始,移动,结束子类的。。。
@property(nonatomic,readonly) NSUInteger tapCount; // touch down within a certain point within a certain amount of time
连续按下的次数。
比如连续按了三次,会产生三个UIEven,每个UIEven里有一个UITouch,第一个UITouch对象的tapCount等于1,第二个UITouch对象的tapCount等于2,第三个UITouch对象的tapCount等于3。
@property(nonatomic,readonly,retain) UIWindow *window;
指向当前UItouch对象所属的UIWindows对象。
@property(nonatomic,readonly,retain) UIView *view;
指向当前UItouch对象所属的UIView对象。
@property(nonatomic,readonly,copy) NSArray *gestureRecognizers NS_AVAILABLE_IOS(3_2);
表示手势。。
- (CGPoint)locationInView:(UIView *)view;
在视图(view参数)上的位置,
- (CGPoint)previousLocationInView:(UIView *)view;
上一个UItouch对象在视图(view参数)上的位置
----------------------------------------------------------------<end>----------------------------------------------