我正在实现具有6-7个屏幕流入的应用程序功能。用户可以在任何屏幕上离开/关闭流程。
但是,当用户再次申请某个应用程序时,他们应该跳到他离开的最后一个屏幕,而且他还可以返回到先前的屏幕。
例如:我开始申请申请,直到第4个屏幕并关闭。再次申请,我必须直接跳到第4个屏幕,并且还必须从堆栈返回第3个-> 2nd->第一个屏幕。
当前代码:Storyboard
中从1到7的屏幕的序列识别为“ screen1”,“ screen1” ...“ screen7”
从HomeScreen.m
-(void)toPersonalApplication {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Personal" bundle:nil];
ScreenOne *screenOne = [storyboard instantiateViewControllerWithIdentifier:@"screenOne"];
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:screenOne];
[self presentViewController:nav animated:YES completion:nil];
}
检查用户是否已经开始申请流程:
在ScreenOne.m
- (IBAction)btnNextClick:(id)sender {
if (doneProcessTill == 4) {
// Should be execute something like this here
// [self performSegueWithIdentifier:@"screen2" sender:self];
// [self performSegueWithIdentifier:@"screen3" sender:self];
// [self performSegueWithIdentifier:@"screen4" sender:self];
}
}
感谢您的建议!
谢谢
最佳答案
如我的评论所述,解决方案可能如下所示:
- (void)toPersonalApplication {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Personal" bundle:nil];
NSMutableArray *viewControllers = [NSMutableArray array];
for (NSInteger i = 1; i <= doneProcessTill; ++i) {
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"screen%ld", (long)i]];
[viewControllers addObject:viewController];
}
UINavigationController *navigationController = [UINavigationController new];
navigationController.viewControllers = viewControllers;
[self presentViewController:navigationController animated:YES completion:nil];
}
关于ios - objective-c :在导航 Controller 中添加/执行多次搜索,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56538079/