如何在全屏模式下从拆分视​​图中显示详细视图控制器?

时间:2013-07-02 14:00:54

标签: ios ipad uiinterfaceorientation

我有一个拆分视图,它有主控和详细导航控制器。 我希望我的细节VC能够以全屏模式呈现其内容。

这就是我所拥有的:

-(void) tapFullscreenBtn{
    UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
    UIWindow *topWindow = [[UIWindow alloc] initWithFrame: mainWindow.bounds];
    topWindow.backgroundColor = [UIColor purpleColor];
    topWindow.windowLevel = UIWindowLevelStatusBar + 1.0f;

    self.view.frame = mainWindow.bounds;
    self.navigationController.view.frame = mainWindow.bounds;

    [topWindow addSubview:self.navigationController.view];
    [topWindow makeKeyAndVisible];

    [self.navigationController.view setNeedsLayout];
    [self.view setNeedsLayout];
}
不幸的是,这段代码不起作用。我得到的结果是:

enter image description here

2 个答案:

答案 0 :(得分:0)

mgsplitviewcontroller为您提供必要的功能

- (IBAction)toggleMasterView:(id)sender; // toggles display of the master view in the current orientation.

答案 1 :(得分:0)

好的我用这个解决了这个问题:

-(void) tapFullscreen {
    if(!_isFullscreenMode)
    {
        MySplitDetailViewController *fullscreenVC = [[MySplitDetailViewController alloc] init];
        fullscreenVC.isFullscreen = YES;
        UINavigationController* fullscreenNavVC = [[UINavigationController alloc] initWithRootViewController:fullscreenVC];
        [self.navigationController presentViewController:fullscreenNavVC animated:YES completion:nil];
    }
    else
    {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }
}