19

I have a UITableView that I'd like to always show the reorder control, never show the little delete circle icon, and always allow for a swipe delete. Is this possible?

So far, I've only discovered two options:

  • Allowing just the swipe-to-delete (UITableViewCellEditingStyleDelete),
  • Allowing just the reorder control (setEditing:YES, UITableViewCellEditingStyleNone).

Thanks for reading

Rogare
  • 3,234
  • 3
  • 27
  • 50
  • I've come across this post: http://stackoverflow.com/questions/1436153/enabling-swipe-to-delete-while-showing-reorder-controls-on-uitableview. Not promising, but also several years old. – Rogare Dec 27 '13 at 21:13
  • Same problem, to remove the left side indented delete controls also disables the swipe to delete. – jmoz Nov 06 '14 at 13:33
  • Did you find a solution? Also finding it strange that you can't swipe to delete without round red icon), and reorder at the same time... – User Dec 26 '14 at 23:29
  • Couldnt't do perfectly with any tweaks. What I did is implemented reorder first and used https://github.com/moritzsternemann/SwipyCell library for swipe to delete. It worked perfectly – Varun Mar 21 '18 at 13:18

3 Answers3

3

To do this I combined two open source projects into:

https://github.com/adamraudonis/UITableViewCell-Swipe-for-Options

Hope that helps! Currently you can reorder by long-pressing anywhere in the TableViewCell and swipe to delete without showing the red circle.

Adam Raudonis
  • 118
  • 1
  • 10
3

Apparently UITableView has a private api method to do just that:

Reorder with swipe-to-delete demo

if ([self.tableView respondsToSelector:@selector(_setAllowsReorderingWhenNotEditing:)]) {
    [self.tableView _setAllowsReorderingWhenNotEditing:YES];
} else {
    // do not ignore this branch 
}

Works in iOS 8, 9 and current betas. However, it is your responsibility to check for method availability to avoid crashes. Still would be better than using some overloaded 3rd party library (which most probably will break in future iOS releases).

Roman B.
  • 3,598
  • 1
  • 25
  • 21
1

I've checked this issue again for iOS 8 and keeping together swipe-removing and reorder control unfortunately still isn't supported from the UITableView API. So you need to add non-standard swipe and reorder tool.

80% completed implementation, which contains both required features:

https://github.com/simonnickel/SNLInteractionTableView.

All you need here is to replace swipe logic with only dragging UITableView cell to the left. And replace hidden/shown image with delete button

skyylex
  • 855
  • 1
  • 10
  • 24
  • 2
    Note that [link-only answers](http://meta.stackoverflow.com/tags/link-only-answers/info) are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Aug 20 '15 at 10:26