我正在尝试在UINavigationController中使用此代码:
http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html
在故事板中:
在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模拟器时,我看不到navigationBar。替换CGPointZero是不够的。
怎么了?
答案 0 :(得分:0)
我找到了一种将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;
}