2
votes

I am trying to use this code inside an UINavigationController :

http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html

In storyboard :

  • I embed PageViewController in Navigation Controller.
  • I change Topbar to "NavigationBar".
  • I add a title : "ImageView" to NavigationBar.
  • I add a storyboard id to PageViewController and NavigationController.

In ImageViewScrollView.m :

- (void)displayTiledImageNamed:(NSString *)imageName size:(CGSize)imageSize

I change this line :

_zoomView = [[UIImageView alloc] initWithFrame:(CGRect){CGPointZero, imageSize }];

By these :

CGPoint navPoint = CGPointMake(0, 45);
_zoomView = [[UIImageView alloc] initWithFrame:(CGRect){navPoint, imageSize}]; 

And I change these lines too :

- (CGPoint)minimumContentOffset
{
    return CGPointZero;
}

By these :

- (CGPoint)minimumContentOffset
{
    CGPoint navPoint = CGPointMake(0, 45);
    return navPoint;
}

And I don't see navigationBar when I use iOS Simulator. Replacing CGPointZero is not enough.

What's wrong ?

1

1 Answers

0
votes

I found an easier way to put photoscroller inside UINavigationController.

I just added in appdelegate.h :

@property (nonatomic, retain) UINavigationController *navController;

and in appdelegate.m :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // kick things off by making the first page
    PhotoViewController *pageZero = [PhotoViewController photoViewControllerForPageIndex:0];
    if (pageZero != nil)
    {
        // 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];

        self.navController = [[UINavigationController alloc] initWithRootViewController:pageViewController];
        [[self window] setRootViewController:_navController];   
    }
return YES;

}