Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在UITableViewCell中未检测到轻触手势_Ios_Swift_Uitableview_Uigesturerecognizer_Uitapgesturerecognizer - Fatal编程技术网

Ios 在UITableViewCell中未检测到轻触手势

Ios 在UITableViewCell中未检测到轻触手势,ios,swift,uitableview,uigesturerecognizer,uitapgesturerecognizer,Ios,Swift,Uitableview,Uigesturerecognizer,Uitapgesturerecognizer,我试图在UITableViewCell内的UIImageView上检测到点击手势 这是cellforrowatinexpath中的代码部分: let cell1 : cellTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! cellTableViewCell tableView.allowsSelection = false cell1.profileImg

我试图在UITableViewCell内的UIImageView上检测到点击手势

这是
cellforrowatinexpath
中的代码部分:

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:")

除非在类cellTableViewCell中实现了tappedOnImage函数。如果是这种情况,那么我会尝试在该类中添加手势识别器,而不是在CellForRowatineXpath所在的任何位置。是的,所有内容都在CellForRowatineXpathui手势识别器中,它是一个抽象类。在cellForRowAtIndexPath方法中,使用UITapGestureRecognitizer