6
votes

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?

2
Make sure you are not reloading the UITableView more often than is necessary. This will abort the built-in gesture recognizer for swipe to delete. - Daniel
Only using reload in two places, I put breakpoints on each one and neither is being triggered - dMurdZ
Did you figure this out? Just curious about how you fixed it... - matt
Yes I did, turns out that my view controller's parent class had a gesture attached to it. What I've taken from this is: if you have a gesture recognizer that's working but is acting finicky/ behaving oddly, best bet is that there is a competing gesture. - dMurdZ
Well done! When you get the details of the solution worked out, you should post it as an answer; that's perfectly legal/standard, and is the best way to help others. This is very likely to be a problem that affects others; in iOS 7 especially there are an awful lot of other gesture recognizers floating around. That is why iOS 7 introduces new ways of mediating between the competing claims of gesture recognizers. - matt

2 Answers

4
votes

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.

1
votes

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.)