发送到实例表视图的无法识别的选择器 swift
Unrecognized selector sent to instance tableview swift
在我的 cellFoRowAtIndexPath
中,我想在属于单元格的按钮上添加一个功能。
在我的 cellFoRowAtIndexPath
中,我添加了这段代码。
cell.acceptBtn.addTarget(self, action: "acceptRequest", forControlEvents: .TouchUpInside)
然后我这里有这个功能。
func acceptRequest(sender: UIButton) {
println("hello");
}
当我 运行 项目并单击该单元格上的按钮时,我得到一个
Terminating app due to uncaught exception 'NSInvalidArgumentException' unrecognized selector sent to instance
需要注意的是,我有另一个按钮,我使用了完全相同的方式,叫做 declineRequest
,它工作得很好。
尝试以下操作:
cell.acceptBtn.addTarget(self, action: "acceptRequest:", forControlEvents: .TouchUpInside)
...注意它是 "acceptRequest:"
而不是 "acceptRequest"
。后者暗示该函数没有参数。
在我的 cellFoRowAtIndexPath
中,我想在属于单元格的按钮上添加一个功能。
在我的 cellFoRowAtIndexPath
中,我添加了这段代码。
cell.acceptBtn.addTarget(self, action: "acceptRequest", forControlEvents: .TouchUpInside)
然后我这里有这个功能。
func acceptRequest(sender: UIButton) {
println("hello");
}
当我 运行 项目并单击该单元格上的按钮时,我得到一个
Terminating app due to uncaught exception 'NSInvalidArgumentException' unrecognized selector sent to instance
需要注意的是,我有另一个按钮,我使用了完全相同的方式,叫做 declineRequest
,它工作得很好。
尝试以下操作:
cell.acceptBtn.addTarget(self, action: "acceptRequest:", forControlEvents: .TouchUpInside)
...注意它是 "acceptRequest:"
而不是 "acceptRequest"
。后者暗示该函数没有参数。