[英]UIButton in custom cell not working
I have a button
in a custom cell
我在自定义cell
有一个button
class CardTableViewCell: UITableViewCell {
@IBOutlet weak var detailsButton: UIButton!
}
in my view controller
then I do this 在我的view controller
然后执行此操作
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//.....more code....
openDealCell.detailsButton.addTarget(self, action: "push:", forControlEvents: UIControlEvents.TouchUpInside)
}
and then: 然后:
func push(sender:AnyObject) {
println("tap")
}
But when I clicked the button
nothing happens. 但是,当我单击button
什么也没有发生。
What I am doing wrong? 我做错了什么?
Fix it! 修理它! The problem was not in the code but in my cell in the storyboard: 问题不在于代码,而在于故事板中的单元格:
where user interaction for the cell wasn't enabled and all the other view didn't allow the user interaction. 其中未启用该单元的用户交互,而所有其他视图均不允许该用户交互。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.