Janoz
Janoz

Reputation: 33

How to block tap gesture on UIPageViewController with Scroll TransitionStyle

I want to block the tap gesture (perfectly just the left border one, but both will be also fine, I will just add button for it) which is responded for changing pages in UIPageViewController.

I already tried this solution in 'viewDidLoad' method:

for recognizer in gestureRecognizers {
    if recognizer is UITapGestureRecognizer {
        recognizer.isEnabled = false
    }
}

But it worked only for the case when TransitionStyle is set for Page Curl, in my case I need to use Scroll TransitionStyle.

Ps. I also found a comment in UIPageViewController implementation that gestureRecognizers are populated only if transition style is UIPageViewControllerTransitionStylePageCurl so there will be needed some bigger "hack", hope you can help me with it.

Pps. Yes I found this - UIPageViewController returns no Gesture Recognizers in iOS 6 . solution but it's pretty old and in objC and I would be glad to use Swift here.

Ppps. Setting dataSource on nil won't work - I need swipe gesture.

Upvotes: 1

Views: 119

Answers (1)

m1sh0
m1sh0

Reputation: 2361

You need to implement the UIGestureDelegate and then to declane gesture when such are detected.

I think here you can see good example how to do it

Upvotes: 0

Related Questions