Event Handling Guide for UIKit Apps 阅读笔记

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 View

  • Motion and remote control events 传递给first responder
    大致有这么几类:Device Orientation、Shake Gestures、Accelerometer Events、Gyroscope Events

事件响应:由下到上,自己不能响应时,传给其父类

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我愿是你生命的踌躇,梦的一方,谁的思念在跳动,生命的节奏无法躲藏。爱恨悠悠,悠悠情长,欢欢喜喜,悲悲乐乐。都说那月...
    烟雨小浩阅读 281评论 0 0
  • 在高等代数课写下我对生活的绝望。为什么要绝望,像他们一样老老实实的上课,做题,学习不是很好吗?我到底想干嘛?既然知...
    Amarla阅读 194评论 0 0
  • 交流,资讯,游戏,办公 随时随地 便携毒品
    半截朽木阅读 234评论 0 0
  • 姓名:严露露 公司:宁波大发化纤有限公司 《六项精进》289期反省一组学员 【日精进打卡第4天】 【知~学习】 《...
    严露露阅读 110评论 0 0