【发布时间】:2011-08-27 04:47:30
【问题描述】:
我在UISplitViewController 上遇到了轮换问题。在我的例子中,在splitViewController(这个 splitViewController 是窗口的根视图)上调用 present modal 之后显示另一个视图。当 modalView 旋转时,splitView 旋转不正确。
splitView 看起来像是旋转的,但 DetailViewController 保持在纵向上的样子,而 RootViewController 根本没有显示。它仍然像在纵向模式下一样。似乎 splitView 旋转了,但底层视图没有旋转(DetailViewController 和 RootViewController)。
我尝试在modalView上实现willRotateToInterfaceOrientation,并使用委托调用splitView的willRotateToInterfaceOrientation方法。
这是我在modalView中实现的:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
MacProjectAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.splitViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
结果是,DetailViewController 行为正确,但 RootViewController 不正确。它保持隐藏。用户手动旋转为纵向并返回横向后,它将重新出现。但显然用户不希望这样。
这是我在展示 modalView 时所做的:
ModalViewController *modalView = [[ModalViewController alloc] init];
MacProjectAppDelegate *delegate = (MacProjectAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.splitViewController presentModalViewController:modalView animated:YES];
[modalView release];
在这种情况下有没有办法显示RootViewController?还是我做事不对?
编辑:
似乎所有视图都没有跟随 modalView 旋转。 RootViewController 和 DetailViewController 都没有旋转(两个 ViewController 上的the didRotateFromOrientation 根本没有调用)。所以现在我假设它没有跟随 device/modalView 旋转。
【问题讨论】:
-
您是否尝试过从
DetailViewController而不是直接从 UISplitView 展示您的 modalViewController? -
我试过了,但它不起作用。到目前为止,我锻炼的解决方案是获取
appDelegate并让splitViewController调用willRotateToInterfaceOrientation两次。一个在modalView的willRotateToInterfaceOrientation方法,一个在RootViewController的willAppear方法。但是这种方法还是有问题的。The DetailViewController仍然显示导航按钮,就像它处于纵向模式时一样。我还在做这个。 -
我遇到了同样的问题。在这里查看我的解决方案stackoverflow.com/questions/7767302/…
标签: ipad rotation uisplitviewcontroller