I've encountered a problem the same as UIScrollview enable delete row by swipe
It is a tableView and another view work as subViews of a scrollView , and I can't enable "swipe to delete" until I set the scrollEnable property of the scrollView to NO , but it brings another problem : I can't swipe between the tableView and another view
Is there any ways other than setting the scrollEnable property to enable "swipe to delete" ?
If not , when should I set self.scrollEnable = NO
, and when should I set self.scrollEnable = YES
to have the "swipe to delete" and "swipe between views" both work fine ?
Thank you
I've successfully used
in a UIScrollView subclass containing the tableview to enable a UISwipeGestureRecognizer residing in the tableview to trigger instead of being swallowed by the "main" scrollview's gesture recognizers.
If , I'm not mistaken , the touches are consumed by the scrollview and the editing of the table is not happening because the table is not getting the touches. This can be resolved by subclassing the UIScrollView in order to snd the touches to the next responder too. So it's just a matter of overrwriting the touchesBegan, moved and ended. Will update the answer later today with the code needed as I am on the road now. Cheers!
EDIT:
Just create a class that inherits from
UIScrollView
and in the implementation drop this code. This will make the scrollView to not swallow the touches, but pass them on. Obviously , when creating your scrollView use the class you just created instead ofUIScrollView
. Sorry for the delay. Hope this helps.Cheers!
You need to use custom subclass of
UIScrollView
. It should works with table views in horizontal scroll views:I know this thread is old, but here is the swift 4 version, working in iOS 11 for me (You would subclass UIScrollView):
@THOR's answer is okay, but if your
UITableView
is in aUIScrollView
, you probably have anotherUIView
in there too. When you scroll up on thetableview
, you accidentally slide over to the "other view".This will prevent the sliding, and allow you to swipe to delete.
}