swift之在tableview中如何知道自己点击的是那个cell中的控件

1 button控件

    cell.addBtn.tag = indexPath.row   //设置button的tag 为tableview对应的行
    //加入button手势事件
    cell.addBtn.addTarget(self, action: "touchUpButton:", forControlEvents: UIControlEvents.TouchUpInside)

func touchUpButton(sender: UIButton){
    
    println(sender.tag)
    
}

2 UIImage

    cell.headImage.userInteractionEnabled = true
    var signTap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "touchUpImage:")
    cell.headImage.addGestureRecognizer(signTap)
    signTap.view!.tag = indexPath.row

func touchUpImage(recognizer: UITapGestureRecognizer){
    
    println( recognizer.view!.tag)

}

3

你可能感兴趣的:(swift之在tableview中如何知道自己点击的是那个cell中的控件)