0

So the UIPageViewController by default seems to be consuming touch events when I tap the left or right side of the screen, changing the active page.

I have a next button in the controller on the bottom right of the screen, but it's only sometimes receiving my events because the controller is consuming them with it's default behavior. How can I disable this left and right tapping behavior?

I've seen all of the similar answers, but none of the solutions worked for me.

Note that I'm NOT using storyboards.

Bassinator
  • 1,682
  • 3
  • 23
  • 50
  • `UIPageViewController` should not be consuming taps. When you disable the page view controller's user interaction, the buttons work perfectly? – trndjc Mar 12 '18 at 16:23
  • No, they don't. They *sometimes* receive events. What I mean is that tapping on the left or right side of the screen changes to the previous or next page automatically, as desired. Sometimes the events get through to my buttons, sometimes they don't. – Bassinator Mar 12 '18 at 16:25
  • What I want to do is disable to the tap to change page function of UIPageViewController without disabling tapping on the control altogether (so that my buttons can still receive events) – Bassinator Mar 12 '18 at 16:26
  • This questioner appears to be having the same problem, but his solution (being in Objective C) doesn't seem to work for me (though perhaps I'm not converting it correctly) - https://stackoverflow.com/questions/12083124/uipageviewcontroller-traps-all-uitapgesturerecognizer-events?noredirect=1&lq=1 – Bassinator Mar 12 '18 at 16:30
  • Where are these buttons placed? On the children of the container or on the container itself? – trndjc Mar 12 '18 at 16:32
  • I'm calling a method in `viewDidLoad()` which runs the following: `let bottomControlsContainerView = UIStackView(arrangedSubviews:[skipButton, pageControl, nextOrGotItButton])` and then `view.addSubview(bottomControlsContainerView)` – Bassinator Mar 12 '18 at 16:35
  • Throw some code up. – trndjc Mar 12 '18 at 16:47

0 Answers0