我在cellForRowAtIndexPath中有这个
cell.plusBut.tag = indexPath.row
cell.plusBut.addTarget(self, action: "plusHit:", forControlEvents: UIControlEvents.TouchUpInside)
Run Code Online (Sandbox Code Playgroud)
而这个功能在外面:
func plusHit(sender: UIButton!){
buildings[sender.tag].something = somethingElse
}
Run Code Online (Sandbox Code Playgroud)
是否有可能发送indexPath.row 和 indexPath.section,或某些替代?
谢谢!
编辑
我这样接近它:
我的自定义按钮
class MyButton: UIButton{
var myRow: Int = 0
var mySection: Int = 0
}
Run Code Online (Sandbox Code Playgroud)
我的自定义细胞
class NewsCell: UITableViewCell{
@IBOutlet weak var greenLike: MyButton!
Run Code Online (Sandbox Code Playgroud)
在CellForRowAtIndexPath中
cell.greenLike.myRow = indexPath.row
Run Code Online (Sandbox Code Playgroud)
我在这一行上收到错误.