1 button控件
<code>
cell.addBtn.tag = indexPath.row //设置button的tag 为tableview对应的行
//加入button手势事件
cell.addBtn.addTarget(self, action: "touchUpButton:", forControlEvents: UIControlEvents.TouchUpInside)
</code>
<code>
func touchUpButton(sender: UIButton){
println(sender.tag)
}
</code>
2 UIImage
<code>
cell.headImage.userInteractionEnabled = true
var signTap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "touchUpImage:")
cell.headImage.addGestureRecognizer(signTap)
signTap.view!.tag = indexPath.row
</code>
<code>
func touchUpImage(recognizer: UITapGestureRecognizer){
println( recognizer.view!.tag)
}
</code>
网友评论