Swipe to delete on a tableView that is inside a pageViewController

I’ve got a tableView inside of a pageViewController and when swiping on a cell to bring up the option to delete the cell the gesture is only recognized under certain circumstances, say you swiped very quickly and aggressively.

I imagine this is happening because it’s not sure whether the swiping gesture is meant for the pageView or the tableView. Is there a way to specifically determine where the swipe gesture is happening to enable a nice smooth display of the delete button?

  • PageViewController delegate functions called twice
  • iOS - UIPageViewControllerDataSource method called twice
  • Disable UIPageViewController bouncing - Swift
  • How to use UIPageViewController to also display a part of the previous and next views
  • Assertion failure in UIQueuingScrollView didScrollWithAnimation:force:
  • How to Build A Dynamic UIPageViewController
  • Solutions Collect From Internet About “Swipe to delete on a tableView that is inside a pageViewController”

    I had the same problem. I found a solution that works well.

    Put this in your UIPageViewController‘s viewDidLoad func.

    if let myView = view?.subviews.first as? UIScrollView {
        myView.canCancelContentTouches = false

    PageViewControllers have an auto-generated subview that handles the gestures. We can prevent these subviews from cancelling content touches. The tableview will be able to capture swipes for the delete button, while still interpreting swipes that fail the tableview’s gesture requirements as page swipes. The delete button will show in cases where you hold and swipe or swipe “aggressively.”