Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.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类中的UIImageView时如何打开新屏幕?_Ios_Swift_Uitableview_Uiimageview_Uigesturerecognizer - Fatal编程技术网

Ios 点击UITableViewCell类中的UIImageView时如何打开新屏幕?

Ios 点击UITableViewCell类中的UIImageView时如何打开新屏幕?,ios,swift,uitableview,uiimageview,uigesturerecognizer,Ios,Swift,Uitableview,Uiimageview,Uigesturerecognizer,我的TableViewCell在它自己的类VersionCellVC中 我的视线完全遮住了牢房;因此,用户别无选择,只能点击UIImageView,而不是TableViewCell 我想执行一个序列或演示一个vc,我已经创建了手势识别器及其调用的函数。但是,由于我在UITableViewCell的自定义子类中,系统告诉我,我不允许使用当前(vc:animate:complete)或准备(forSegue:…)函数,因为它们不是UITableViewCell类的成员 如何在不将UIImageVie

我的TableViewCell在它自己的类VersionCellVC中

我的视线完全遮住了牢房;因此,用户别无选择,只能点击UIImageView,而不是TableViewCell

我想执行一个序列或演示一个vc,我已经创建了手势识别器及其调用的函数。但是,由于我在UITableViewCell的自定义子类中,系统告诉我,我不允许使用
当前(vc:animate:complete)
准备(forSegue:…)
函数,因为它们不是UITableViewCell类的成员


如何在不将UIImageView更改为UIButton的情况下解决此问题?

类似的情况(在包含tableview的viewcontroller中)如何

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) as! CustomCell

    cell.myImageView?.isUserInteractionEnabled = true
    cell.myImageView?.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(imageViewTapped(imageView:))))

    return cell
}

func imageViewTapped(imageView: UIImageView) {
    if let indexPath = tableView.indexPathForRow(at: imageView.convert(.zero, to: tableView)) {
        print("user tapped imageview at indexPath \(indexPath)")
    }
}