2016-03-03 107 views
1

如何獲得的次數屏幕中迅速被觸動我不如何計算快速觸摸屏幕的次數?

知道使用哪種方法,請大家幫忙

+0

是否意味着屏幕上的觸摸次數或觸摸次數? – ZeMoon

+0

檢查此問題http://stackoverflow.com/questions/26829295/swift-getting-the-coordinates-from-the-location-i-touch-the-touchscreen/34735546#34735546 – kb920

回答

2

這是很簡單的,只是在聲明頂部的櫃檯,var counter = 0

然後使用功能,只需鍵入的touchesBegan它會顯示

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
    counter++ 
    print(counter) 
} 
+0

謝謝@Lee你的回答幫了我很多,但我有一個問題,如果有任何方法使用滑動手勢來製作該計數器。我的意思是在滑動動作函數內部沒有touchesBegan函數。 再次感謝:) –

+0

@AhmedAssemMostafa你是什麼意思的刷卡行動? – Lee

+0

對於這個方法不會調用的按鈕動作,如何獲取? –

0

創建靜態無功計數器= 0
計數器應該是靜態變量。

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { 
counter++ 
print(counter) 
}