Ios 移动到另一个没有UINavigationController的情节提要
我有两个故事板。我找到了一些代码,说明了如何实例化另一个故事板的初始视图控制器,并将其移动(或者说segue?)。但这些示例使用了导航控制器。在我的案例中,用户不能返回到上一个情节提要(登录页面)。该应用程序可以忘记旧的故事板,当我转到新的故事板时,就不再需要它了 因此,可以忘记第一个Storybard中层次结构顶部的视图控制器,我不希望它成为下一个故事板的演示者。它不应该存在,演示者和层次结构的顶部现在应该是第二个故事板的初始视图控制器Ios 移动到另一个没有UINavigationController的情节提要,ios,iphone,objective-c,uinavigationcontroller,storyboard,Ios,Iphone,Objective C,Uinavigationcontroller,Storyboard,我有两个故事板。我找到了一些代码,说明了如何实例化另一个故事板的初始视图控制器,并将其移动(或者说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;
}];
非常完整详细的回答,非常感谢!我要试试看!非常完整详细的回答,非常感谢!我要试试看!此处跟进问题:此处跟进问题: