【问题标题】:frame size of detail view of splitviewcontroller does not change up in ios4.2splitviewcontroller 的详细视图的帧大小在 ios4.2 中没有改变
【发布时间】:2010-12-17 11:29:42
【问题描述】:

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

请帮助我。 谢谢 修罗提

【问题讨论】:

    标签: objective-c uisplitviewcontroller ios-4.2


    【解决方案1】:

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

    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];
    

    【讨论】:

    • 这只是我为解决问题所做的替代方法。它不完全是所提问题的答案。
    猜你喜欢
    • 1970-01-01
    • 2015-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-01
    • 2013-02-24
    • 2021-10-13
    相关资源
    最近更新 更多