Kus*_*tha 2 uitableview swipe swift
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
if condition == true {
let pause = UITableViewRowAction(style: .Destructive, title: "pause") { action, index in
print("pause button tapped")
return [pause]
}
} else {
return .None
}
}
Run Code Online (Sandbox Code Playgroud)
此代码并未禁用在单元格中滑动。但是当滑动时会出现单元格删除选项。请任何人都可以帮助解决这个问题。
您需要根据您的情况使用canEditRowAt它并返回值。Bool
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
if condition == true {
return true
}
return false
}
Run Code Online (Sandbox Code Playgroud)
无需检查editActionsForRowAtIndexPath方法中的条件。
| 归档时间: |
|
| 查看次数: |
1285 次 |
| 最近记录: |