-
-
Save steipete/10541433 to your computer and use it in GitHub Desktop.
- (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]; | |
} |
@subdigital Tweeted this resource: http://nsscreencast.com/episodes/110-swipe-to-reveal-redux
Even Apple's engineers are mad about this: https://twitter.com/andy_matuschak/status/455353641658880001
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.
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.
This looks very promising: https://github.com/runmad/RMSwipeTableViewCell
Finally, this has been solved in iOS8!
@LeoNatan -- Where? Can't seem to find documentation on it in iOS 8. Thx!
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
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.
@scheinem Sorry, but your implementation (MSC) is an insult to coding. Replacing Apple's private api calls with scrambled stringWithFormat and invocations? seriously?
Options for adding the "More" button like Mail does:
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
onNSMutableArray
or adispatch_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.