Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@steipete

This comment has been minimized.

Copy link
Owner Author

@steipete steipete commented Apr 12, 2014

Options for adding the "More" button like Mail does:

Cell

https://github.com/scheinem/MSCMoreOptionTableViewCell
Uses private API and KVO'ing (!) the layer hierarchy, is basically a lot of code and less "safe" than the above. It does allow more customization of the buttons, so if you want a green "More" button, that's the way to go.

https://github.com/daria-kopaliani/DAContextMenuTableViewController
Uses a pan gesture recognizer and custom views for the buttons. Not bad, but feels differently than a scroll view just because the pan move gesture has different timing - it's very hard to simulate the UIScrollView bouncing. Also deeply tied to the UITableViewController, if you use something else you're in trouble.

https://github.com/CEWendel/SWTableViewCell
Uses a custom scroll view. Has some really weird ideas about configurations that include methods like sw_addUtilityButtonWithColor on NSMutableArray or a dispatch_once_t as class ivar (!!) ... but good from an approach point of view.

https://github.com/TeehanLax/UITableViewCell-Swipe-for-Options
Most compact solution by Ash Furrow, uses a scroll view. Needs a few tweaks in scrollViewWillEndDragging: to better determine if the buttons should be displayed or hidden. Otherwise very simple and effective.

Please add links to your solutions if you have anything better (or a good open source variant that I've missed)

Sample implementation is here:
https://github.com/PSPDFKit/PSPDFKit-Demo/blob/master/Examples/PSPDFCatalog/Customization/PSCCustomAnnotationCellExample.m
(Might not build until we've released PSPDFKit 3.7 later this week)

Maybe an even better function would be to make the UIScrollView accessible, so we don't have to put in our own scroll view into that scrollView, and could build more sophisticated solutions like swiping the other side.

@steipete

This comment has been minimized.

Copy link
Owner Author

@steipete steipete commented Apr 12, 2014

@steipete

This comment has been minimized.

Copy link
Owner Author

@steipete steipete commented Apr 13, 2014

Even Apple's engineers are mad about this: https://twitter.com/andy_matuschak/status/455353641658880001

@chebur

This comment has been minimized.

Copy link

@chebur chebur commented Apr 13, 2014

Please, take a look at the https://github.com/chebur/ELActionCell
Implementation is a quite complicated but the behavior is realy close to the Mail.app's one.

@MrAlek

This comment has been minimized.

Copy link

@MrAlek MrAlek commented Apr 24, 2014

For future reference, I got my App Store app approved using the above mentioned, undocumented delegate calls, compiled with the iOS 7.1 SDK. Might mean Apple will make them public in a future release.

@phatmann

This comment has been minimized.

Copy link

@phatmann phatmann commented Apr 27, 2014

@LeoNatan

This comment has been minimized.

Copy link

@LeoNatan LeoNatan commented Jun 24, 2014

Finally, this has been solved in iOS8!

@Phoebe719

This comment has been minimized.

Copy link

@Phoebe719 Phoebe719 commented Jun 25, 2014

@LeoNatan -- Where? Can't seem to find documentation on it in iOS 8. Thx!

@siancu

This comment has been minimized.

Copy link

@siancu siancu commented Jun 30, 2014

Look for UITableViewRowAction. It seems it has been added in beta2, so far could only find a reference in the API diffs between beta1 and beta2: https://developer.apple.com/library/prerelease/ios//releasenotes/General/iPhoneSeedAPIDiffs/index.html

Also I couldn't get it to work at the moment, but I suppose I'm doing something wrong, as there is at least one person who got it to work: https://twitter.com/marksands/status/481642991745265664

@scheinem

This comment has been minimized.

Copy link

@scheinem scheinem commented Jul 6, 2014

Here is a working example: https://gist.github.com/scheinem/e36835db07486e9f7e64

As I mentioned in the comments make sure you've also implemented tableView:commitEditingStyle:forRowAtIndexPath: in you UITableViewController.

BTW: I updated MSCMoreOptionTableViewCell to be compatible with iOS 8 (beta 2) and added some other functionality.

@Elaz

This comment has been minimized.

Copy link

@Elaz Elaz commented Jul 20, 2014

@scheinem Sorry, but your implementation (MSC) is an insult to coding. Replacing Apple's private api calls with scrambled stringWithFormat and invocations? seriously?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment