fortmarek / SwipeViewController

SwipeViewController is a Swift modification of RKSwipeBetweenViewControllers - navigate between pages / ViewControllers
MIT License
655 stars 46 forks source link

Restrict swipe gesture to a certain area #16

Open suprb opened 8 years ago

suprb commented 8 years ago

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?

fortmarek commented 8 years ago

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

relaxsus commented 6 years ago

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

fortmarek commented 6 years ago

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 🤓

relaxsus commented 6 years ago

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
fortmarek commented 6 years ago

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! 🎊

relaxsus commented 6 years ago

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

SeasiaInhouse commented 6 years ago

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

fortmarek commented 6 years ago

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