iOS手勢識別初探

2021-06-21 08:32:43 字數 559 閱讀 5235

uigesturerecognizerstate的定義如下:

typedef

ns_enum(nsinteger, uigesturerecognizerstate) ;

uigesturerecognizerstatepossible

預設狀態,手勢識別器尚未識別出手勢,但是可能已經在處理觸屏事件了。

uigesturerecognizerstatebegan

手勢識別器識別出了手勢,接下來將會執行action方法。

uigesturerecognizerstatechanged

手勢識別器識別出了手勢的改變,接下來將會執行action方法。

uigesturerecognizerstateended

手勢結束狀態

uigesturerecognizerstatecancelled

手勢撤銷

uigesturerecognizerstatefailed

無法識別

uigesturerecognizerstaterecognized

已經識別手勢,接下來置為預設狀態。

iOS 手勢識別

首先給大家解釋一下為什麼要學習手勢識別?如果想監聽乙個uiview上面的觸控事件,之前的做法是 自定義乙個uiview 實現uiview的touches方法,在方法裡面實現具體功能 透過touches監聽uiview的觸控事件,有很明顯的幾個缺點 1.必須要自定義uiview,2.由於是在view內...

iOS各種手勢識別

import viewcontroller.h inte ce viewcontroller property nonatomic,strong uiimageview imageview end implementation viewcontroller synthesize imageview ...

iOS 手勢識別器概述

其相應的方法 initwithtarget action addtarget action removetarget action locationinview locationoftouch inview numberoftouches屬性 requiregesturerecognizertofa...