iosipaduiinterfaceorientation

How to show detail view controller from split view in fullscreen mode?


I have a split view, which has master and detail navigation controllers. I want my detail VC be able to present its content in fullscreen mode.

that's what I have atm:

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

unfortunately this code doesn't work. All I have in result is:

enter image description here


Solution

  • ok I've solved the problem with this:

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