Mik*_*e U 6 uitableview ios swift uitableviewrowaction
我有以下swift代码来实现UITableViewRowAction,当我滑动一行时,行按预期向左滑动,但是所有Section Header Rows也同时向下滑动到表行.
我还包括一个屏幕截图来显示正在发生的事情
如果我删除viewForHeader覆盖并用titleForHeaderInSection替换它,那么我没有问题.
覆盖viewForHeader的原因是我想在Header Row中放置一个图像.
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCellWithIdentifier("header") as UITableViewCell
cell.textLabel?.text = instrumentGroups[section].name
cell.imageView?.image = UIImage(named: instrumentGroups[section].name)
return cell
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> InstrumentTableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("instrumentCell", forIndexPath: indexPath) as InstrumentTableViewCell
cell.instrument = instrumentGroups[indexPath.section].instruments[indexPath.row]
return cell
}
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
let instrument = instrumentGroups[indexPath.section].instruments[indexPath.row]
var actions: [AnyObject] = []
var action = UITableViewRowAction(style: .Normal, title: "Remove Watch") { (action, indexPath) -> Void in
tableView.editing = false
instrument.SetWatchList(false)
self.refresh()
}
action.backgroundColor = UIColor.redColor()
actions.append(action)
return actions
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
}
Run Code Online (Sandbox Code Playgroud)

Wiz*_*kid 23
只需返回cell.contentView而不是cell在viewForHeaderInSection函数中,您的问题就会得到解决.
| 归档时间: |
|
| 查看次数: |
2469 次 |
| 最近记录: |