简体   繁体   中英

Swift : How to set two action on Single Gesture

I am working on a iOS app, where i have couple of tiles. When user touch one of these tiles, function tileTapped1 gets called.

I have used UITapGestureRecognizer for this as per the code below:

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:以添加第二个回调方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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