Reputation: 2573
I am currently working on a solution where I need to have a UITableView
by default in reorder mode without having a delete button but could enable the delete button when necessary. I am just curious if this is even achievable in iOS? If so what should be my approach for this?
Upvotes: 0
Views: 185
Reputation: 146
In my opinion your table view should always be in edit mode.
To make the reorder controls appear you should implement UITableViewDataSource methods
tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool
and
tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath)
If you don't want the delete button to be displayed you can do that by implementing
tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle
and return .none by default or .delete when you want to have the button displayed.
Upvotes: 1