2012-02-12 2 views
4

Я пытался следующее, и ничего не работает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 на pageViewOptions является 2, NSLog в spineLocation 1. Это сводит меня вверх по стене, все, что я хочу сделать, это Инициализация с позвоночником посередине. Он всегда инициализируется слева. приложение инициализируется в ландшафте, но только после поворота устройства на 180 градусов метод »- (UIPageViewControllerSpineLocation) pageViewController: (UIPageViewController *) pageViewController spineLocationForInterfaceOrientation: (UIInterfaceOrientation) ориентация« работает, а затем я получаю позвоночник посередине. может кто-то пролить свет на это. Я искал всюду для ответа.

все, что я хочу, чтобы это сделать, это инициализируется в пейзаж с позвоночником в середине

ответ

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]; 
Смежные вопросы