0

私はUIPageViewControllerを実装していますが、初期化後にデバイスを回転させてもSpineLocationを正しく設定しても、すべて正常に動作しますが、

UIPageViewController をインスタンス化すると、デバイスが横向きの場合、1 ページ (UIPageViewControllerSpineLocationMin) だけで UIPageViewController が作成されます...

読み込みませんm trying to instantiate it using UIPageViewControllerSpineLocationMid just like the code below (and like developer.apple recommends) BUT when i do it... the UIPageViewController doesn...

NSDictionary * options = [NSDictionary dictionaryWithObject:
        [NSNumber numberWithInt:UIPageViewControllerSpineLocationMid]
forKey:UIPageViewControllerOptionSpineLocationKey];

UIPageViewController *pageViewController = [[UIPageViewController alloc]
initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
  navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                options:options]

何か問題がありますか?ありがとう!

4

1 に答える 1

2

このデリゲートを使用します。

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController  *)pageViewController
               spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if(UIInterfaceOrientationIsPortrait(orientation))
{
 //Set the array with only 1 view controller
    UIViewController *currentViewController = [self.pageController.viewControllers objectAtIndex:0];
    NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
    [self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];

    //Important- Set the doubleSided property to NO.
    self.pageController.doubleSided = NO;
    //Return the spine location
    return UIPageViewControllerSpineLocationMin;

 }

else
{
NSArray *viewControllers = nil;

    exampleViewController *currentViewController = [self.pageController.viewControllers objectAtIndex:0];

    NSUInteger currentIndex = [self.VControllers indexOfObject:currentViewController];

    if(currentIndex == 0 || currentIndex %2 == 0)
    {
        UIViewController *nextViewController = [self pageViewController:self.pageController viewControllerAfterViewController:currentViewController];
        viewControllers = [NSArray arrayWithObjects:currentViewController, nextViewController, nil];
    }
    else
    {
        UIViewController *previousViewController = [self pageViewController:self.pageController viewControllerBeforeViewController:currentViewController];
        viewControllers = [NSArray arrayWithObjects:previousViewController, currentViewController, nil];
    }
    //Now, set the viewControllers property of UIPageViewController
    [self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];

    return UIPageViewControllerSpineLocationMid;
}
}
于 2012-12-08T11:19:26.280 に答える