gpt4 book ai didi

ios - Objective-C : Add/Perform multiple segue in navigation controller

转载 作者:行者123 更新时间:2023-11-28 23:30:59 24 4
gpt4 key购买 nike

我正在实现一个有 6-7 个屏幕流入的应用程序功能。用户可以在任何屏幕上离开/关闭流程。

但是当用户再次申请时,他们应该跳转到他离开的最后一个屏幕,并且他可以回到之前的屏幕。

例如:我开始申请申请并完成到第 4 个屏幕并关闭。再次申请,我必须直接跳转到第 4 个屏幕,并且还能够从堆栈返回到第 3->2->1 个屏幕。

当前代码:

Storyboard 中屏幕 1-7 的 Segue identifires 是“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];
}

检查用户是否已经开始一个应用程序:

On 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 : Add/Perform multiple segue in navigation controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56538079/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com