添加手势 swift

来源:互联网 发布:学通网络红尘ai教程 编辑:程序博客网 时间:2024/05/29 09:37

tableviewcell 上的图片添加单击手势

cell.iconImageView.addGestureRecognizer(UITapGestureRecognizer(target: self ,action: #selector(iconClick(_:))))// 注意这个 点击没有反应的话把这个打开iconImageView.userInteractionEnabled = true

点击方法

func iconClick(gestureRecognizer: UITapGestureRecognizer) {        var getIndexPath = NSIndexPath()        getIndexPath = tableView.indexPathForRowAtPoint(gestureRecognizer.locationInView(tableView))!        print("\(getIndexPath.section)section \(getIndexPath.row) line")    }
0 0