Cyril
Cyril

Reputation: 1236

UIPageViewController not working properly

I am using UIPageViewController to load 10 webpages in a webview.

All the webpages are loading one by one properly. But I am facing a weird problem in

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController

Right now I am in 1st page. So there are no possibility of going back to the

- (UIViewController *)pageViewController:(UIPageViewController *) pageViewController viewControllerBeforeViewController:(UIViewController *)viewController

After I load the 1st page, I was just scrolling up and down with the WebView. Suddenly the viewControllerAfterViewController method is getting called. And strange thing is , it is not moved to the next view i.e (2nd page) is not loaded.

What could be the problem ?

Upvotes: 0

Views: 3216

Answers (1)

lawrence fletcher
lawrence fletcher

Reputation: 26

I'm not sure but, I think the problem is in the gesture recognizers, or the location of there CGRects. Basically the page view controller listens for a touches-move. So if the user swipes the scroll (on the webView) page view tries to execute a page turn. (I'm guessing) I think a solution would be to make sure the page view touch location (CGRect) does not overlap with the web view. Apparently you can set the position (region) for the touch for the UIPageViewController" to turn the page.

You can start by looking up "UIGestureRecognizer Class Reference" in the iOS Reference Library. I hope this helps

Here's what I found there:

locationInView: Returns the point computed as the location in a given view of the gesture represented by the receiver.

  • (CGPoint)locationInView:(UIView *)view Parameters view A UIView object on which the gesture took place. Specify nil to indicate the window. Return Value A point in the local coordinate system of view that identifies the location of the gesture. If nil is specified for view, the method returns the gesture location in the window’s base coordinate system.

Discussion The returned value is a generic single-point location for the gesture computed by the UIKit framework. It is usually the centroid of the touches involved in the gesture. For objects of the UISwipeGestureRecognizer and UITapGestureRecognizer classes, the location returned by this method has a significance special to the gesture. This significance is documented in the reference for those classes.

Availability Available in iOS 3.2 and later. See Also – locationOfTouch:inView: Declared In UIGestureRecognizer.h locationOfTouch:inView: Returns the location of one of the gesture’s touches in the local coordinate system of a given view.

  • (CGPoint)locationOfTouch:(NSUInteger)touchIndex inView:(UIView *)view Parameters touchIndex The index of a UITouch object in a private array maintained by the receiver. This touch object represents a touch of the current gesture. view A UIView object on which the gesture took place. Specify nil to indicate the window. Return Value A point in the local coordinate system of view that identifies the location of the touch. If nil is specified for view, the method returns the touch location in the window’s base coordinate system.

Availability Available in iOS 3.2 and later. See Also – locationInView: Declared In UIGestureRecognizer.h

Upvotes: 1

Related Questions