The new 'swipe to delete' look and feel in iOS 7 added a 'bounce' effect where the UITableViewCell continues to offset after a swipe. Is there any way to disable this bounce, so that the cell makes a hard stop once the delete button is fully visible?
Cell that continues to offset:
I want the cell to stop here even if dragging continues:
I tried this in my cellForRowAtIndexPath:
method, but nothing seemed to change.
for(UIView *subview in cell.subviews){
if([subview isKindOfClass:[UIScrollView class]]){
UIScrollView *theScrollView = (UIScrollView *)subview;
theScrollView.bounces = NO;
}
}
I think I finally found a solution! Using a custom cell, you can set that cell as a
UIScrollViewDelegate
and implement thescrollViewDidScroll:
method. In that method, you can force the UIScrollView's contentOffset to stay under a particular value (I'm using82.0f
because that seems to be the contentOffset when the 'Delete' button is fully visible). Like this:.h
.m
This can also be done without using a custom cell by simply setting a ViewController as a
UIScrollViewDelegate
and setting the UIScrollView's delegate intableView:cellForRowAtIndexPath
like so:.h
.m
I dont think there is an option for that but perhaps what you can do is subclass your cell and in
didTransitionToState:
you can detect the delete confirmation state.Now at this point im not entirely sure what you can do to prevent the scrolling but I hope this puts you in the right direction.
Maybe you can disable the cell's gesture recognizer in this state?
try this for your custom delete button
https://gist.github.com/JigsChanchiya/7002903#file-customswipetodelete-mm