私は私のアプリでUITableViewController
を実装していると私はまさにこの答えのように、私のテーブルビューのセルをスワイプ/スライドの可能性を追加したい:すべてではなく、Swipe-able Table View Cell in iOS 9それは1つの特定のセルのために働く差そのうちの。Swiftの特定のUITableViewCellに対してのみeditActionsForRowAtIndexPathを実装する方法はありますか?
class MyTableViewController: UITableViewController {
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
override func tableView(tableView: (UITableView!), commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: (NSIndexPath!)) {
}
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
var deleteAction = UITableViewRowAction(style: .Default, title: "Hello There!") {action in
print("some action!!")
}
return [deleteAction]
}
}
をし、それがすべてのセルのスワイプを追加し、私は私のリスト上の第3回1(細胞が動的に生成されていない)に追加したい:これまでのところ私が持っています。それをする方法はありますか?
ですが、数値3と比較できるintの 'indexPath'ですか?この場合、どのくらい正確にそれを行うことができますか? – randomuser1
[OK]を3 – dan
に 'indexPath.row'を比較することができますので、私はやった:'場合(indexPath.row == 2){VARのdeleteAction = UITableViewRowAction(...}他{戻りはnil} 'が、まだそれがスライドすることが可能ですすべてのセル。その解決策と私の3番目のセルに、私は 'こんにちはあり、文字列を参照してください!'と私は、文字列 'DELETE'を参照してください他のものをスライドさせます。完全に、他の細胞をスライドさせる可能性を除去する方法はありますか? :) – randomuser1