SwipeViewController icon indicating copy to clipboard operation
SwipeViewController copied to clipboard

Restrict swipe gesture to a certain area

Open andreas-pihlstrom opened this issue 9 years ago • 8 comments

Is there any way to restrict the pan/swipe to a certain area? I'd like to leave the bottom part of my view as an area where it ignores the gesture. Is it doable?

andreas-pihlstrom avatar Sep 11 '16 15:09 andreas-pihlstrom

Since SwipeViewController subclasses UIPageViewController it should be possible. Try looking at this code: https://gist.github.com/TosinAF/805a22ab5a3e4ffe17a8/

fortmarek avatar Sep 12 '16 17:09 fortmarek

Okay, but if I need tableView gestures to work? How realize it?

relaxsus avatar Apr 06 '18 11:04 relaxsus

I have not tried this myself, but please do try to use the gist I shared above. You can implement part of it in SwipeViewController.swift syncScrollView() function. Any PRs are welcome 🤓

fortmarek avatar Apr 06 '18 13:04 fortmarek

In SwipeViewController.swift

    open var isSwiping = true

inside func setPageController()

    pageController.delegate = self
    if isSwiping {
            pageController.dataSource = self
    }

In YourViewController: SwipeViewController where you want to disable swipe

    isSwiping = false

relaxsus avatar Apr 06 '18 15:04 relaxsus

Hmm, interesting solution, I will take a look at it tomorrow. This is for disabling swiping for one ViewController as a whole, and not a part of it, but still could be useful for some people out there! 🎊

fortmarek avatar Apr 06 '18 17:04 fortmarek

Yes, it is for disabling the whole ViewController. I needed just it:)

relaxsus avatar Apr 06 '18 17:04 relaxsus

What if I want to disable swiping in ViewController: UIViewController not ViewController: SwipeViewController

SeasiaInhouse avatar Jul 31 '18 05:07 SeasiaInhouse

@SeasiaInhouse, could you please describe your problem more thoroughly? Thanks.

fortmarek avatar Jul 31 '18 14:07 fortmarek