我从 Apple 的网站上获取了Photo Scroller示例,并尝试通过复制代码来实现我自己的相册。现在,UIScrollView
是不可见的。我如何让它出现?
我所做的唯一代码更改是在创建UIPageViewController
. 在我的情况下,它UIViewController
是打开它而不是AppDelegate
.
@implementation BasePhotoViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nil bundle:nibBundleOrNil];
if (self) {
// 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 *) [[UIApplication sharedApplication] keyWindow].rootViewController;
UIPageViewController *pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:0 navigationOrientation:0 options:nil];
//UIPageViewController *pageViewController = (UIPageViewController *)self.parentViewController;
pageViewController.dataSource = self;
[pageViewController setViewControllers:@[pageZero]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:NULL];
}
}
return self;
}