繁体   English   中英

在UITableViewCell中未检测到点击手势

[英]Tap gesture not detected in UITableViewCell

我正试图在UITableViewCell内的UIImageView上检测到一个轻击手势。

这是cellForRowAtIndexPath代码的一部分:

let cell1 : cellTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! cellTableViewCell


        tableView.allowsSelection = false
        cell1.profileImg.userInteractionEnabled = true

        let tappedOnImage = UIGestureRecognizer(target: cell1, action: "tappedOnImage:")

        cell1.profileImg.tag = indexPath.row
        cell1.profileImg.addGestureRecognizer(tappedOnImage)

这是处理手势的功能:

func tappedOnImage(sender:UITapGestureRecognizer){


    print("hey")
}

但是,当我点击任何建议时,什么也没发生?

如果没有看到更多代码,很难说出错了,但试试这个:

let tappedOnImage = UITapGestureRecognizer(target: self, action: "tappedOnImage:")

暂无
暂无

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

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