触摸屏的手指数(Swift 2.0)

触摸屏的手指数(Swift 2.0),swift,numbers,touch,uigesturerecognizer,Swift,Numbers,Touch,Uigesturerecognizer,我有个问题 我想让我的iPhone显示有多少手指触摸屏幕。。。我用触摸开始和触摸结束。我的iPhone显示了触摸屏幕的手指数量,但仅当我用手指同时触摸时(2、3或4…)。我希望它在添加一个或多个手指时显示手指数 非常感谢你的帮助 PS:很抱歉我的英文更新了Swift 3: override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { super.touchesBegan(touches

我有个问题

我想让我的iPhone显示有多少手指触摸屏幕。。。我用触摸开始和触摸结束。我的iPhone显示了触摸屏幕的手指数量,但仅当我用手指同时触摸时(2、3或4…)。我希望它在添加一个或多个手指时显示手指数

非常感谢你的帮助

PS:很抱歉我的英文更新了Swift 3:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

    super.touchesBegan(touches, with: event)
    var countTouch = event?.allTouches?.count

//Do whatever you want with that
}
override func touchsbegind(touch:Set,带有事件:UIEvent?){
super.touchesbeated(touches,with:event)
var countTouch=事件?.alltouch?.count
//你想用它做什么都行
}
如果您想知道它是否在任何时候发生了变化,请在TouchsMoved中执行相同的操作,并将其放入数组中,您可以分析它或直接打印它

像这样:

var countTouch:[Int] = []

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

    super.touchesBegan(touches, with: event)
    countTouch.append((event?.allTouches?.count)!) //Not really necessary

//Do whatever you want with that
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesMoved(touches, with: event)
    countTouch.append((event?.allTouches?.count)!)
}
var countTouch:[Int]=[]
覆盖func TouchesBegind(Touchs:Set,带有事件:UIEvent?){
super.touchesbeated(touches,with:event)
countTouch.append((事件?.alltouch?.count)!)//实际上不需要
//你想用它做什么都行
}
覆盖功能触摸移动(touchs:Set,带有事件:UIEvent?){
super.touchesMoved(touches,with:event)
countTouch.append((事件?.alltouch?.count)!)
}
希望它能帮助别人,不要犹豫编辑或改进它。我是Swift的初学者,所以完全可能有错误