Swift:如何在Single Gesture上设置两个动作

时间:2015-07-08 17:44:41

标签: ios swift uitapgesturerecognizer

我正在开发一款iOS应用,我有几块瓷砖。当用户触摸其中一个图块时,将调用tileTapped1函数。

我根据以下代码使用了UITapGestureRecognizer:

let gestureRecognizer = UITapGestureRecognizer(target: self, action: "tileTapped1:")
gestureRecognizer.numberOfTapsRequired = 1
tile[index].addGestureRecognizer(gestureRecognizer)

我需要你的帮助才能理解当用户使用磁贴时有没有办法调用两个函数。例如:

let gestureRecognizer = UITapGestureRecognizer(target: self, action1: "tileTapped1:", action2:"tileTapped2:")
gestureRecognizer.numberOfTapsRequired = 1
tile[index].addGestureRecognizer(gestureRecognizer)

1 个答案:

答案 0 :(得分:0)

您可以在手势识别器上再次调用addTarget:action:添加第二个回调方法。