相关疑难解决方法(0)

通过Button Swift中的标签发送行和部分

我在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)

我在这一行上收到错误.

button uitableview ios sender-id swift

5
推荐指数
2
解决办法
6475
查看次数

标签 统计

button ×1

ios ×1

sender-id ×1

swift ×1

uitableview ×1