Gestures
- 手势分为两种,分散的、连续的,分散的给其target单一动作信号,连续的需要发送持续信号。
- The userInteractionEnabled property of the view is set to YES.
Image views and labels set this property to NO by default.
点击:UIPanGestureRecognizer
- The number of taps was equal to the number specified in the numberOfTapsRequired property.
- The number of fingers was equal to the number specified in the numberOfTouchesRequired property.
长按:UILongPressGestureRecognizer
- The tap duration was greater than what is specified in the minimumPressDuration property.
拖动:UIPanGestureRecognizer
- The number of touches is between the values specified in the minimumNumberOfTouches and maximumNumberOfTouches properties.
- For a UIScreenEdgePanGestureRecognizer object, the edges property is configured and touches started at the appropriate edge.
滑动:UISwipeGestureRecognizer
A swipe requires the user’s finger to move in a specific direction and not deviate significantly from the main direction of travel.
The direction of the swipe matches the value in the direction property.
捏合:UIPinchGestureRecognizer
- At least two fingers are touching the screen.
- You are applying scale factors to your content correctly. Exponential growth of a value happens when you simply apply the scale factor to the current value.
旋转:UIRotationGestureRecognizer
- You are applying rotation factors to your content correctly. Over-rotation happens when you apply the same rotation value more than once. To fix this problem, set the rotation property to 0.0 after applying the current rotation value to your content.
处理多个手势时,遵守这个代理 UIGestureRecognizerDelegate 的 shouldRecognizeSimultaneouslyWithGestureRecognizer 方法,可以解决多个手势冲突的问题。
Responders
A responder object -> UIResponder class -> UIApplication/UIViewController/UIView
Events continue to flow up the responder chain until they are handled.
事件传递:UIApplication -> UIWindow -> 根据事件类型,传递给Object
事件类型可以分为:
Touch events 传递给发生touch事件的view,也就是 hit-test View
Hit-testing 检查touch事件发生在哪个view上,迭代的检查是否发生在这个view上,其最小的包含touch事件发生点的view成为hit-test ViewMotion and remote control events 传递给first responder
大致有这么几类:Device Orientation、Shake Gestures、Accelerometer Events、Gyroscope Events
事件响应:由下到上,自己不能响应时,传给其父类