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

事件響應:由下到上,自己不能響應時,傳給其父類

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 我愿是你生命的躊躇,夢的一方,誰的思念在跳動,生命的節奏無法躲藏。愛恨悠悠,悠悠情長,歡歡喜喜,悲悲樂樂。都說那月...
    煙雨小浩閱讀 275評論 0 0
  • 在高等代數課寫下我對生活的絕望。為什么要絕望,像他們一樣老老實實的上課,做題,學習不是很好嗎?我到底想干嘛?既然知...
    Amarla閱讀 186評論 0 0
  • 交流,資訊,游戲,辦公 隨時隨地 便攜毒品
    半截朽木閱讀 234評論 0 0
  • 姓名:嚴露露 公司:寧波大發化纖有限公司 《六項精進》289期反省一組學員 【日精進打卡第4天】 【知~學習】 《...
    嚴露露閱讀 110評論 0 0