我有5个视图控制器,想要从最后一个视图返回到第一个视图控制器
答案 0 :(得分:0)
在动画启动画面上使用此方法
[self performSelector:@selector(setHidden:) withObject:nil afterDelay:2.0];
-(void) setHidden:(id)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboare" bundle:nil];
YourVC* vController = (YourVC*)[Storyboard instantiateViewControllerWithIdentifier:@"storyboardId"];
UINavigationController *navcotoller=[[UINavigationController alloc]initWithRootViewController:vController];
self.window.rootViewController =navcotoller;
}
答案 1 :(得分:0)
调用一个必须更改应用程序rootviewcontroller的函数。将其设置为navigationController
yourViewcontoller *viewController = [[yourViewContoller alloc] init];
UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:viewController];
self.window.rootViewController = navController;
答案 2 :(得分:0)
如果您正在使用故事板,请为UINavigationController提供故事板ID。然后,您可以启动它并通过代码显示:
UINavigationController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"<Storyboard ID>"];
[self presentViewController:vc animated:YES completion:nil];
答案 3 :(得分:0)
如果您使用的是UINavigationController
,则可以而且只需致电
[self.navigationController popToRootViewControllerAnimated:YES];