2012-02-12 17 views
4

私は次のことをしようとしていると何もpageViewOptionsでUIPageViewControllerや風景

NSDictionary *pageViewOptions = [NSDictionary dictionaryWithObjectsAndKeys:UIPageViewControllerOptionSpineLocationKey, [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid],nil]; 
NSLog(@"pageViewOptions :%@",pageViewOptions);  

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:pageViewOptions];  
NSLog(@"spineLocation :%d",self.pageViewController.spineLocation); 

にのNSLogを作業していないが2である、spineLocationでのNSLog 1.これは私が行いたいことがあり、壁に私を運転していますさ真ん中に脊柱を初期化する。常に左に初期化されます。 (UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation " が働いていて、途中で背骨になってしまいます。誰かがこれにいくつかの光を当ててください。私はどこでも答えを探しました。

私はそれが何をしたいすべては「オプション」パラメータを使用してみてください真ん中

答えて

8

に背骨と風景の中に初期化される:

NSDictionary *options = (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) ? [NSDictionary dictionaryWithObject: [NSNumber numberWithInteger:UIPageViewControllerSpineLocationMid] forKey: UIPageViewControllerOptionSpineLocationKey] : nil; 

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:options]; 

... 

そして2つのコンテンツビューコントローラを初期化することを忘れないでください:

NSArray *viewControllers = [NSArray arrayWithObjects:contentViewController1, contentViewController2, nil]; 

[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];