0

I have used page-based application example shipped with xcode to build my app. The page view controller works fine, however, I have such problem:

In each view controller representing page data, I have some buttons, and clicking it leads to another view controller's view. I use this to add the view to view hierachy:

[self.view addSubview: self.articleViewController.view];

articleViewController just has a scrollview inside and show some text data. The problem is, if I swipe the view to scroll up/down, when it reaches the end page view controller takes this gesture and move to previous/next page, which not what I want. I want articleViewController receives no gestures from page view controller but only scrolling itself.

Hopefully I described good enough..

How can I disable gestures in my articleViewController? I have tried to study this post: UIPageViewController Gesture recognizers but haven't figured it out to solve my problem.

An example project to illustrate the problem: https://dl.dropbox.com/u/43017476/PageTest.zip

Community
  • 1
  • 1
chenxee
  • 335
  • 3
  • 10

1 Answers1

0

I know you cited the same question, but I don't like the accepted answer. Check out this answer, which is a bit further down the same post. I had the same issue and adding the block of code from that answer to the end of my viewDidLoad in my UIPageViewController fixed the issue I was having.

Basically what's happening is that the UIPageViewController is consuming all of the touch events, so you need to remove certain UIGestureRecognizers from the UIPageViewController so that it doesn't respond to those. It might be a little trickier than the example I posted as that is just removing UITapGestureRecognizer, but it's the same basic concept. You need to make sure that the UIPageViewController only advances to the next page on a right->left swipe gesture, and not an up->down swipe gesture.

Check out the UISwipeGestureRecognizerDirection documentation.

Community
  • 1
  • 1
DiscDev
  • 38,652
  • 20
  • 117
  • 133