Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 移动到另一个没有UINavigationController的情节提要_Ios_Iphone_Objective C_Uinavigationcontroller_Storyboard - Fatal编程技术网

Ios 移动到另一个没有UINavigationController的情节提要

Ios 移动到另一个没有UINavigationController的情节提要,ios,iphone,objective-c,uinavigationcontroller,storyboard,Ios,Iphone,Objective C,Uinavigationcontroller,Storyboard,我有两个故事板。我找到了一些代码,说明了如何实例化另一个故事板的初始视图控制器,并将其移动(或者说segue?)。但这些示例使用了导航控制器。在我的案例中,用户不能返回到上一个情节提要(登录页面)。该应用程序可以忘记旧的故事板,当我转到新的故事板时,就不再需要它了 因此,可以忘记第一个Storybard中层次结构顶部的视图控制器,我不希望它成为下一个故事板的演示者。它不应该存在,演示者和层次结构的顶部现在应该是第二个故事板的初始视图控制器 我如何才能做到这一点?要做到这一点,您需要: 实例化第二

我有两个故事板。我找到了一些代码,说明了如何实例化另一个故事板的初始视图控制器,并将其移动(或者说segue?)。但这些示例使用了导航控制器。在我的案例中,用户不能返回到上一个情节提要(登录页面)。该应用程序可以忘记旧的故事板,当我转到新的故事板时,就不再需要它了

因此,可以忘记第一个Storybard中层次结构顶部的视图控制器,我不希望它成为下一个故事板的演示者。它不应该存在,演示者和层次结构的顶部现在应该是第二个故事板的初始视图控制器


我如何才能做到这一点?

要做到这一点,您需要:

  • 实例化第二个故事板
  • 从第二个情节提要实例化所需的视图控制器
  • 将窗口的根控制器更改为新的视图控制器
  • 这就是你如何做到的:

    //Instantiate the second Storyboard
    UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"SecondStoryBoard" bundle:nil]; 
    
    //Instantiate new VC, you will need to set the Storyboard Identifier of the VC to @"postLoginRoot" in your second storyboard
    UIViewController *newRootVC = [secondStoryboard instantiateViewControllerWithIdentifier:@"postLoginRoot"];
    
    //swap the root view controllers of the window
    //nb: change the animation type as you see fit
    UIAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    UIWindow *mainWindow = delegate.window;
    
    [mainWindow  insertSubview:newRootVC.view belowSubview:mainWindow.rootViewController.view];
    
    [UIView transitionWithView:mainWindow
                          duration:0.8
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^{
                            [mainWindow.rootViewController.view removeFromSuperview];
                        }
                        completion:^(BOOL completed){
                            mainWindow.rootViewController=newRootVC;
                        }];
    

    为此,您需要:

  • 实例化第二个故事板
  • 从第二个情节提要实例化所需的视图控制器
  • 将窗口的根控制器更改为新的视图控制器
  • 这就是你如何做到的:

    //Instantiate the second Storyboard
    UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"SecondStoryBoard" bundle:nil]; 
    
    //Instantiate new VC, you will need to set the Storyboard Identifier of the VC to @"postLoginRoot" in your second storyboard
    UIViewController *newRootVC = [secondStoryboard instantiateViewControllerWithIdentifier:@"postLoginRoot"];
    
    //swap the root view controllers of the window
    //nb: change the animation type as you see fit
    UIAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
    UIWindow *mainWindow = delegate.window;
    
    [mainWindow  insertSubview:newRootVC.view belowSubview:mainWindow.rootViewController.view];
    
    [UIView transitionWithView:mainWindow
                          duration:0.8
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^{
                            [mainWindow.rootViewController.view removeFromSuperview];
                        }
                        completion:^(BOOL completed){
                            mainWindow.rootViewController=newRootVC;
                        }];
    

    非常完整详细的回答,非常感谢!我要试试看!非常完整详细的回答,非常感谢!我要试试看!此处跟进问题:此处跟进问题: