截至目前,当我运行程序并点按时,我会在点击一下后收到println()
消息。但是,在第一条println()
消息之后,我必须双击每一条println()
消息。
我希望每次必须双击(包括第一次)。
在我的View Controller中,我有以下内容:
@IBOutlet weak var graphview: GraphView! {
didSet {
//
graphview.addGestureRecognizer(UITapGestureRecognizer(target: graphview, action: "doubleTap:"))
}
}
我在View中的功能如下:
func doubleTap(gesture: UITapGestureRecognizer)
{
gesture.numberOfTapsRequired = 2
println("hit twice")
}
答案 0 :(得分:2)
你必须设置
gesture.numberOfTapsRequired = 2
在将手势识别器添加到视图之前,即
@IBOutlet weak var graphview: GraphView! {
didSet {
var doubleTap: UITapGestureRecognizer = UITapGestureRecognizer(target: graphview, action: "doubleTap:")
doubleTap.numberOfTapsRequired = 2
graphview.addGestureRecognizer(doubleTap)
}
}
和
func doubleTap(gesture: UITapGestureRecognizer)
{
println("hit twice")
}