我有一个以UINavigatonController
. rootViewController
指向一个UIViewController
上面有一个按钮的。按钮 segues (push) 到 a UIPageViewController
。
加载时UIPageViewController
,我以编程方式创建页面视图(由 xib 文件中的另一个视图控制器定义)。
当我运行应用程序时,单击按钮按预期转换,但结果视图始终为空(只是黑屏)。似乎我遗漏了一些非常明显的东西,但几天后我寻求帮助!
这是 viewDidLoad 的代码UIPageViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//Create the content
[self createContentPages];
//Set the initial view controllers.
NSDictionary *options =
[NSDictionary dictionaryWithObject:
[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
forKey: UIPageViewControllerOptionSpineLocationKey];
self.pageController = [[UIPageViewController alloc]
initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options: options];
pageController.dataSource = self;
ContentViewController *contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentViewController" bundle:nil];
contentViewController.dataObject = [self.pageContent objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:contentViewController];
[self.pageController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
[self addChildViewController:self.pageController];
[self.view addSubview:self.pageController.view];
[self.pageController didMoveToParentViewController:self];
//Assign the gestureRecognizers property of our pageViewController to our view's gestureRecognizers property.
self.view.gestureRecognizers = self.pageController.gestureRecognizers;
}