简体   繁体   English

Swift:如何在单一手势上设置两个动作

[英]Swift : How to set two action on Single Gesture

I am working on a iOS app, where i have couple of tiles. 我正在使用一个iOS应用程序,其中有两个磁贴。 When user touch one of these tiles, function tileTapped1 gets called. 当用户触摸这些图块之一时,调用tileTapped1函数。

I have used UITapGestureRecognizer for this as per the code below: 我已经根据以下代码使用了UITapGestureRecognizer:

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

I need your help to understand is there any way to call two function when a user the tile. 我需要您的帮助,以了解在用户平铺时是否有任何方法可以调用两个函数。 For example something like this: 例如这样的事情:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM