我用自定义类将UITableViewCell
子类化了。并增加了一些出口。现在,我想在单元格内的按钮上获取IBAction
。我如何在ViewContoller
本身中定义IBAction。
最佳答案
// In cellForRowAtIndexpath
cell.yourButton.tag=indexPath.row;
button.addTarget(self, action: "buttonHandler:", forControlEvents: UIControlEvents.TouchUpInside)
func buttonHandler(sender:UIButton!)
{
if(sender.tag==0){
println("Button at row 0")
}
else if(sender.tag==1){
println("Button at row 1")
}
}
关于ios - 在单元格中的单击按钮上添加新的单元格行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41560881/