【发布时间】:2016-03-03 08:35:44
【问题描述】:
如何快速获取屏幕被触摸的次数我没有
知道用什么方法,请帮忙
【问题讨论】:
-
你是指当时屏幕上的触摸次数还是点击次数?
标签: ios swift swift2 screen uitouch
如何快速获取屏幕被触摸的次数我没有
知道用什么方法,请帮忙
【问题讨论】:
标签: ios swift swift2 screen uitouch
很简单,在顶部声明一个计数器,var counter = 0
然后使用该功能,只需输入touchesBegan它就会显示
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
counter++
print(counter)
}
【讨论】:
创建静态变量 counter = 0
计数器应该是静态变量。
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
counter++
print(counter)
}
【讨论】: