gpt4 book ai didi

ios - 区分 UITableViewCell 上的单击和双击

转载 作者:行者123 更新时间:2023-11-30 13:54:53 25 4
gpt4 key购买 nike

我在 tableViewCell 中添加了一个 UITapGestureRecogniser ,它可以识别用户是否双击了单元格。如果我双击该单元格,则会自动调用函数 didSelectRowAtIndexPath 。我只希望如果用户在单元格上双击而不是同时双击,则调用手势识别器的函数。有人有办法解决这个问题吗?

最佳答案

在viewDidLoad函数中:

let aSelector : Selector = “start:”
let tapGesture = UITapGestureRecognizer(target: self, action: aSelector)
tapGesture.numberOfTapsRequired = 1
view.addGestureRecognizer(tapGesture)

let bSelector : Selector = “stop:”
let doubleTapGesture = UITapGestureRecognizer(target: self, action: bSelector)
doubleTapGesture.numberOfTapsRequired = 2
view.addGestureRecognizer(doubleTapGesture)

tapGesture.requireGestureRecognizerToFail(doubleTapGesture)

单击时将调用 aSelector 操作,双击时将调用 bSelector。

关于ios - 区分 UITableViewCell 上的单击和双击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33757942/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com