更改UITableViewRowAction内的单元格背景颜色

时间:2015-12-04 18:09:46

标签: ios swift2 uitableviewrowaction

我正在使用UITableViewRowAction编辑iOS Swift 2中的表。如果他们在弹出操作按钮后选择操作,我希望整个单元格的当前背景(而不是按钮弹出窗口)改变颜色。我尝试使用 dequeueReusableCellWithIdentifier 访问它,但没有发生任何事情。

let share = UITableViewRowAction(style: .Normal, title: "Showed Up?") { (action, indexPath) in

let cell = tableView.dequeueReusableCellWithIdentifier("secondtableCell", forIndexPath: indexPath) 
cell.backgroundColor = UIColor.redColor()

......当然,代码会继续关闭。除了颜色变化之外,一切都按预期工作。

1 个答案:

答案 0 :(得分:1)

您是否在ViewDidLoad方法中注册了课程?如果没有,请继续这样做并告诉我你得到了什么。

self.tableViewController.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")