UIPageViewController and swipe gestures

I have a UIPageViewController and on some pages I have sliders.

Unfortunately the slider causes the page to want to swipe to the next page.

So far every every attempt to stop the swipe propagation to the page view controller has failed.

Anyone have a good example of a slider in page controlled by a UIPageViewController that won’t swipe accidentally when the slider is used, would be great.

I’m using Swift.

You can prevent a UIPageViewController from attempting to scroll to another page by setting its datasource to nil. So what you could to is set it to nil when you see a touch beginning inside the slider and returning it when that touch lifts. This would have the effect of making even an obvious swipe gesture (tap and flick) change the slider value only but I think it might be the right thing to do if the gesture begins on the slider.

Thank you. I’ll give it a go.

The solution works nicely, though it doesn’t always kick in quickly enough - but way better than before. The screen that I made have a slider in the middle of the screen, so I’ve actually decided to suppress the swipe dependent on y position, not specifically the slider.

The whole issue made me think that in these situations a custom controller might be even better rather than just using a pageview controller.

Thanks again for a great idea.