我正在iPad应用程序中使用SplitViewController实现两个视图:主视图和详细视图。在将iPad方向从纵向更改为横向时,我需要隐藏主视图并更改详细视图的框架大小以全屏显示。为此,我正在使用以下代码:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
//adjust master view
UIViewController *master = [self.splitViewController.viewControllers objectAtIndex:0];
UIViewController *detail = [self.splitViewController.viewControllers objectAtIndex:1];
CGRect t = master.view.frame;
t.size.width = 0;
t.size.height = 0;
t.origin.x = 0;
t.origin.y = 0;
[master.view setHidden:YES];
[master.view setFrame:t];
//adjust detail view
CGRect f = detail.view.frame;
f.size.width = 1004;
f.size.height = 768;
f.origin.x = 0;
f.origin.y = 0;
[detail.view setFrame:f];
}
这段代码在ios3.2上运行得非常好,但在ios4.2上无法正常工作。主视图在ios4.2中被隐藏了,但详细视图的框架大小没有改变。
请帮助我。 谢谢 Shruti