我有一个包含其他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