1


I'm using UIPageViewController in my application that shows all the images similar to a book. Its working fine.
What I want to do now:
I want to place a button on top left corner and on click it will show a pop over view controller which has a table view with 7 cells. Each cell will show different URL. On click of the table cell, it will push a view controller with web view.

What's the problem The problem is that I placed the button on top left and created a segue to show popover. But on click of button it goes to previous page and on next clicks it will finally reach page 1. then in page 1, it will show the pop over. I didn't understand why is it happening like this.

And even after showing popover, its not showing next view with website.

How to do it?

Satyam
  • 15,493
  • 31
  • 131
  • 244
  • For solution: See Philips response in http://stackoverflow.com/questions/7788780/uipageviewcontroller-gesture-recognizers/7788839#7788839 – Satyam Oct 27 '11 at 14:25

1 Answers1

5

The trick is that UIPageViewController's gesture recognizers take over that area. In particular, the tap handler; so your button only gets hit when the tap recognizer does not take it as meaning to go to the previous page.

Quickest solution is to set yourself to the delegate of its recognizers

for (UIGestureRecognizer *recognizer in pageViewController.gestureRecognizers)
  recognizer.delegate = self;

and then implement the delegate telling them to let controls get touches

- (BOOL)gestureRecognizer:(UIGestureRecognizer *) __unused gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
   if ([touch.view isKindOfClass:[UIControl class]])
      return NO;
   return YES;
}

which ought to sort you nicely.

Alex Curylo
  • 4,744
  • 1
  • 27
  • 37
  • Thanks for this I was having a similar problem but not quite the same. I wanted the Pan gesture recognized but not the tap. So I added another check in the for in loop that checked for the tap recognizer and set that delegate. So the swipe still works and I handle the tap elsewhere. So this solved my issue too! – simongking Jan 26 '12 at 14:31