小编bza*_*adm的帖子

在Swift 3中单击和双击UITableViewCell

我在TableViewCell上有故事板segue,我用它在单击单击didSelectRowAt方法中转移到另一个VC .现在我做了双击TapGestureRecognizer以处理细胞上的轻微敲击.问题是,单击时,segue正在执行,双击不起作用.单击单元格,双击可正常工作.到目前为止我的代码可能以某种方式解决这个问题吗?或者我需要删除segue并单独处理单击和双击.谢谢你的任何建议

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    let doubleTap = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap))
    doubleTap.numberOfTapsRequired = 2
    view.addGestureRecognizer(doubleTap)
}

func handleDoubleTap(recognizer: UIGestureRecognizer) {
    let p = recognizer.location(in: tableView)

    let indexPath = tableView.indexPathForRow(at: p)

    if let _ = indexPath {
        tableView.deselectRow(at: indexPath!, animated: true)
        update(index: (indexPath?.row)!, isFinished: true)
    }

    print ("doubke")
}


override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if (segue.identifier == "showSingleTask") …
Run Code Online (Sandbox Code Playgroud)

uitableview uitapgesturerecognizer swift swift3

2
推荐指数
1
解决办法
4023
查看次数