iOS.Lover
iOS.Lover

Reputation: 6051

issue with UIPageViewController gesture

I am using Erica Sudan's tutorial to show a PDF via UIPageViewController , but there is 2 problems :

1- I can not swipe the book from every corner or every position (the right or left side of the view) I am using apple WWDC 2011 code to swipe from everywhere but does not work :

- (void)viewDidAppear:(BOOL)animated {

    [[[self parentViewController] view] setGestureRecognizers:[self.view gestureRecognizers]];

}

- (void)viewWillDisappear:(BOOL)animated {

    for (UIGestureRecognizer *gesture in [self gestureRecognizers] ) {

        [[[self parentViewController] view] setGestureRecognizers:[self.view gestureRecognizers]];
    }
}

2- It takes a little bit time to recognize the swiping , I mean page curling is not realtime with sliding . I slide left and it takes time to page move with my finger

Thanks

Upvotes: 0

Views: 2333

Answers (1)

Mr. Berna
Mr. Berna

Reputation: 10645

I'm not sure what self is referring to in your code. What needs to happen is that the gesture recognizers associated with the UIPageViewController are assigned to the view holding the UIPageViewController's view. In one of my projects I use this code:

self.view.gestureRecognizers = self.pageViewController.gestureRecognizers;

Where self is a UIViewController subclass with a UIPageViewController property. The view of the UIPageViewController is added as a subview of self.view.

To answer your second issue, drawing a PDF is slow in iOS. The UIPageViewController loads and draws the next (or previous) page of the PDF before it can start animating the page curl transition. If you are displaying spreads, it may have to draw two more pages. Try your code with simple UIImageView objects instead of the PDF views to see if your page view controller code is working correctly. This change should give you a high performance result. Then you'll know that you need to accelerate your PDF drawing.

One thing you can do to accelerate the PDF drawing is to draw preview images asynchronously ahead of when they will be needed. Then use these as the initial drawing of your content views in the page view controller. Once the animation has settled down, then redraw the view from the PDF. The pageViewController:didFinishAnimating:previousViewControllers:transitionCompleted: method should come in handy.

Upvotes: 1

Related Questions