Swipe to delete UITableViewCell very difficult to trigger - ios

So I have a table view and I'd like the user to be able to swipe left to reveal a delete button, identically to how it works in the mail app. My issue is not that I can't get this to work - it does, I can swipe the row left, it reveals a delete button, and the user can click it to delete the cell (I do this by implementing editingStyleForRowAtIndexPath). My issue is that the swipe that is required is extremely insensitive. You have to swipe very fast and perfectly horizontally. It is not nearly as smooth as the swiping in mail. Is this just the way it is or am I overlooking something?
I thought maybe the views in the cell were blocking the swipe gesture somehow, but I went into the xib and set everything to hidden and it still is extremely difficult to swipe. The other thing I tried was to add my own swipe gesture recognizer to trigger the delete show. I tried adding it to the cell (that didn't work), to the table view (nope), and I also tried adding a clear colored UIView as a frontmost subview and putting it on that, but still no. Any ideas?
EDIT:
I just created a new project to test the responsiveness of the editing style delete feature - very very simple table view just to see how it works. It is MUCH easier to swipe than the cell in my actual project. There aren't many differences between my test project and my actual one: actual loads a xib on cellForRowAtIndexPath while in test project it uses default styled cell, actual project has imageviews and uilabels within cell while test project is just a uilabel... what could be making it so unresponsive?

It turns out there was a competing gesture recognizer hidden in a superclass I was completely oblivious to. Once I realized that, it was easily solved by disabling the other recognizer for that screen (although I believe there would be a more correct way of doing it by setting gesture recognizer priorities). Anyway, if you are having similar issues - really strange/ unexpected behavior from a UIGestureRecognizer - I would ensure there is no other gesture recognizer interfering.

You could try to "roll your own". In the built-in UITableView, we are probably responding to a leftward swipe gesture recognizer (the gesture for which, as you say, must be quick and very horizontal in order to recognized). The way this works in Mail, on the other hand, is that the cell contents actually contains a UIScrollView, capable of being scrolled horizontally only - and that is what you are doing when you slide left, just dragging as you would with any scroll view. (That's why you can peek at the Delete button and then drag the message back to the right.)

Related

Swipe does not work with UITableview's scrollview and Pull to Refresh in iOS

I have created UITableView with Scrollview and given swipe gesture to swipe from left to right and vice-versa between three different views. Both of them don't seem to work with each other. On top of this I have a pull to refresh functionality on the UITableView. I have tried to implement UIGestureRecogniser delegate method but it doesn't seem to work.Any Suggestions?
I have realised that when the bouncing is disabled on the scrollview the swipe functionality works fine, but Pull-to-refresh does not work in this case.

UITableViewCell Editing is very difficult to show

I want my table view cell to show the Delete bar on the right side when the user swipes. However, the table view is in a UIScrollView, and although it is at the far right side, and swiping left does not move the scroll view, the table view cell makes it difficult to edit.
In order to trigger the swipe for editing, I must swipe very fast and in a perfectly horizontal line. The speed required is far more than you can expect users to even want to do, and would not be expected at all from a user's perspective.
I believe the scroll view is the cause, but I cannot be certain. No gesture recognizer is present.
How can I prevent the scroll view from mucking up this experience?
Putting a tableView or webView in a scrollView is not advised, because of the exact problem you are having. Your best bet is to find a way around putting it in a scrollView. Other than modifying your tableView to not be in the scrollView, you might try moving your tableView to the front. [superView bringSubviewToFront:tableView]; hope this helps.
You could try using the gesture recognizer delegate methods for this. I don't have Xcode in front of me, but if you use gestureRecognizer:shouldRequireFailureOfGestureRecognizer: and just fail the scrollView's swiping gesture if the gesture recognized is that of the swiping of the table view cell. Check UIGestureRecognizerDelegate in the docs.

UITableViewCell covering delete button on swipe left

I am posting this question, specifically related to iOS 7.
When I swipe cell to left, the delete button appear correctly, but the cell is not moving left enough, which results in the delete button being covered by the cell for nearly half of its width.
The cell is a class extending UITableViewCell, and in Storyboard there's a UIView with some child views in it, but for the rest it is just a plain cell.
The custom class is not implementing any drawing mechanism.
Unless you have some custom code configuring your cell, I would remove the code for this and add it back. There has to be something that you've written in your code to cause this to happen. Usually, this functionality works right out of the box. Post your code so that we can see what's causing the issue.

UITableViewCell horizontal custom swip- to-delete effect

I have a UITableView and would like to have a custom way to delete my cells. When someone swipe on it, the cell would move horizontally on the side and disappear.
Exactly like the multitasking menu on iOS 7 (http://movies.apple.com/media/us/ios/ios7/f34c5445-5a9c-4b3a-9556-8efe89147559/shared_multitasking/shared_multitasking_2x.mp4), but instead of swiping vertically, it would be horizontal.
Does any one knows how to do that? Should I just detect a swipe and change the frame of my cell with a 1 sec animation? Or are there nice subclasses of UITableViewCell you would recommend?
I just threw together a very basic example of how to do this and posted it here: https://github.com/NSPostWhenIdle/MMSwipeToDeleteCollection. Don't expect to be able to drag and drop this into your project and have it work, because quite frankly it probably won't.
The basic idea to create something like this starts with a subclass of UICollectionViewCell that adds a gesture to the cell. In my example, I used a swipe gesture because I'm lazy :p and there is more overhead involved in setting up a pan gesture (which you'll want in your end product) because there is conflict between that pan gesture, and the pan gesture in the collection view's scroll view.
From there it's basically smooth sailing. When the gesture recognizer gets called you animate the cell out the top of the screen. If you set this up with a pan gesture, you'll need to configure this to drag the cell, and animate up or down upon completion, but in my swiping example, the cell moves to just out the top (of the 4 inch simulator, I used static values).
Then all that's left to do is some clean up. Once the cell has exited the screen you can safely delete it from your datasource and then from the collection view. (I used notification center do alert the collection view, but you should probably make a protocol) The only issue I had with this was that the cell animated back down while fading out as part of the stock deletion animation. Setting its alpha to 0 after it leaves the screen solves this problem.

iOS UICollectionView not scrolling when cell is touched

I've created a simple grid based UICollectionView but I'm having trouble with the scrolling. If I touch the view itself rather than a cell within it then it seems to scroll correctly but if I touch one of the cells and try to scroll then nothing happens. This is a bit of an issue, as I basically want the grid of cells to completely fill the view, and when the view is filled like that there is nowhere to touch that will actually make it scroll! I guess the easiest way to describe what I'm trying to achieve is a table view but with two columns of cells rather than one.
I can't seem to find anything in the documentation that talks about this issue and I've tried various combinations of "user interaction enabled" settings etc.
One final thing, I do require the cells to respond to a single tap touch (basically to toggle them on and off) so I don't want to completely disable them responding to touches.

Resources