In the apple PhotoScroller example, 3 zoomable images are displayed in a UIPageViewController
. You can zoom these images and page between them even when they are still zoomed. My application uses the code from the PhotoScroller with the only difference being that my UIPageViewController
is a child view controller of another UIViewController
in my app - i.e. the paging functionality is contained within a view hierarchy. In Apple's version, the UIPageViewController
is the root view controller (set up by a storyboard actually). In my code, I do not get the paging behavior unless I return the content to it's un-zoomed scale. For my app I don't want to force the user to do this. What do I need to do to get this working the way I want to?
UPDATE I have determined that setting the page view controller as the root view controller manually causes the apple example code to exhibit the unwanted behavior. that is, creating the page view controller in app delegate as
// assign the first page to the pageViewController (our rootViewController)
UIPageViewController *pageViewController = [[UIPageViewController alloc] init];
pageViewController.dataSource = self;
[pageViewController setViewControllers:@[pageZero]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:NULL];
self.window.rootViewController = pageViewController;
Causes a zoomed image to simply bounce at the edge, rather than zooming to the next image. Original code is:
// assign the first page to the pageViewController (our rootViewController)
UIPageViewController *pageViewController = (UIPageViewController *)self.window.rootViewController;
pageViewController.dataSource = self;
[pageViewController setViewControllers:@[pageZero]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:NULL];
Why does this break the behavior of scrolling while an image is zoomed ?
SOLVED
UIPageViewController must be initted properly, as
_pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
I had merely called alloc] init]
.
UIPageViewController
must be initiated properly, as
_pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
I had merely called alloc] init]
as a replacement for storyboard
, which is not sufficient.