【问题标题】:Photoscroller inside UINavigationControllerUINavigationController里面的Photoscroller
【发布时间】:2013-02-02 20:36:33
【问题描述】:

我正在尝试在 UINavigationController 中使用此代码:

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

在故事板中:

  • 我在导航控制器中嵌入了 PageViewController。
  • 我将 Topbar 更改为“NavigationBar”。
  • 我在 NavigationBar 中添加了一个标题:“ImageView”。
  • 我向 PageViewController 和 NavigationController 添加了故事板 ID。

在 ImageViewScrollView.m 中:

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

我改变了这一行:

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

通过这些:

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

我也改变了这些行:

- (CGPoint)minimumContentOffset
{
    return CGPointZero;
}

通过这些:

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

当我使用 iOS 模拟器时,我看不到导航栏。替换 CGPointZero 是不够的。

怎么了?

【问题讨论】:

    标签: ios uinavigationcontroller


    【解决方案1】:

    我找到了一种更简单的方法来将 photoscroller 放入 UINavigationController。

    我刚刚在 appdelegate.h 中添加了:

    @property (nonatomic, retain) UINavigationController *navController;
    

    在 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;
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-10
      • 2012-04-09
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      • 2013-02-09
      • 2011-03-11
      相关资源
      最近更新 更多