3

我正在我的 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 中,但细节视图的帧大小不会改变。

请帮我。谢谢施鲁蒂

4

1 回答 1

0

我发现我的问题的替代方法是,我没有隐藏主视图并在旋转时更改详细视图的框架大小,而是将包含详细视图的类作为模态视图呈现。早些时候,我是从上一堂课推它的。我还添加了一个导航栏,带有一个完成按钮来关闭模式视图。这件事对我有用。

ListingViewController *viewController = [[ListingViewController alloc] initWithNibName:@"ListingViewController" bundle:[NSBundle mainBundle]];  
UINavigationController *modalVC = [[UINavigationController alloc]initWithRootViewController:viewController]; // to add navigation bar
modalVC.navigationBar.barStyle = UIBarStyleBlackOpaque;
[self.navigationController presentModalViewController:modalVC animated:YES];
[modalVC release];
[viewController release];
于 2010-12-22T06:57:41.687 回答