我有一個包含其他ViewControllers的UIViewController。初始視圖控制器設置在viewDidLoad中:容器視圖控制器中UIPageViewController的旋轉
FirstViewController *first = [FirstViewController alloc] init];
first.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
first.view.frame = m_content.frame;
[self addChildViewController:first];
[m_content.view addSubview:first.view];
[first didMoveToParentViewController:self];
m_activeViewController = first;
此容器控制器已經實施automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers返回YES。它還實施manualy正向旋轉改變非活躍ViewControllers
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
for(UIViewController *vc in m_viewControllers)
{
if(vc != [m_activeViewController]
[vc willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
for(UIViewController *vc in m_viewControllers)
{
if(vc != [m_activeViewController]
[vc didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
當菜單按鈕被竊聽我做ViewControllers之間的過渡。
- (void)onMenuItemTapped:(id)sender
{
UIViewController *vc = [m_viewControllers objectAtIndex:sender.tag];
vc.view.frame = m_content.frame;
[self addChildViewController:vc];
[self transitionFromViewController:m_activeViewController toViewController:vc duration:0 options:UIViewAnimationOptionTransitionNone animations:nil completion:^(BOOL finished) {
[vc didMoveToParentViewController:self];
[m_activeViewController removeFromParentViewController];
m_activeViewController = vc;
}];
}
這種轉變工作正常,我的「正常」 ViewControllers和他們方位的變化後正常顯示,即使他們不積極。但是,其中一個子視圖控制器稱爲SecondCV,它具有UIPageViewController作爲子視圖控制器。我有UIPageViewControllerDelegate和UIPageViewControllerDataSource設置爲此SecondCV和pageViewController:spineLocationForInterfaceOrientation:我回UIPageViewControllerSpineLocationMin的肖像和UIPageViewControllerSpineLocationMid景觀。此SecondVC的旋轉功能在其處於活動狀態時正常工作 - 在橫向上有兩頁,在縱向模式下正確顯示了一頁。但是當這個SecondVC不活躍時,旋轉是不正確的。即使調用了pageViewController:spineLocationForInterfaceOrientation:,縱向和橫向模式中仍然有一個頁面。我試圖解決這一段時間,但我沒有看到任何其他選項。你有什麼想法如何解決這個問題?
謝謝。
我也使用頁面視圖控制器,我已經添加了VC到一個數組,但不知道過渡各種VC的正確方式,我如何移動到下一個VC使用頁面捲曲轉換。你可以請指導我或發佈一些示例代碼。 – 2012-11-28 07:11:57
[鏈接](https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html)我想你可以在這裏找到所有的想法,如果沒有,請聯繫我 – DaNY 2012-12-06 10:48:44
我還沒有解決方案,請看看我的問題,如果你能指導我。 「http://stackoverflow.com/questions/13776894/uipageviewcontroller-change-from-two-page-mode-to-one-page-mode-without-changi#comment18942540_13776894」 – 2012-12-08 11:44:18