OGeek|极客世界-中国程序员成长平台

标题: ios - 初次入职后如何过渡到主应用程序流程 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:51
标题: ios - 初次入职后如何过渡到主应用程序流程

目前我在 storyboard 中有两个流程:入职/登录流程(当前设置为 storyboard 设置中的初始 View Controller )和主应用程序流程(例如,您登录后的核心应用程序体验)。

从入门到主应用流程的转换在 UI 中成功地发生了,但我认为我这样做的方式不太正确。我遇到的一个问题是无法将 View 状态恢复到主应用程序流。

当从入职流程过渡到主应用流程时,我使用 presentViewController 来过渡到新的 View Controller ,然后我正在从中删除呈现 View Controller 的父导航 Controller 使用 removeFromParentViewController 查看层次结构。我的想法是主应用程序流应该有它自己的 View 层次结构,其根应该是新呈现的 View Controller 中的第一个 View 。

但是,以这种方式执行操作会破坏 View 恢复代码。似乎我无法正确地将 View 层次结构“重置”到主导航 Controller 。在我没有从 View 层次结构中删除载入导航 Controller 之前, View 状态恢复工作正常(如下面的代码所示),但现在它不起作用——状态总是恢复到载入流程的开头,- (void)decodeRestorableStateWithCoderNSCoder *)coder 方法永远不会在主应用程序流 Controller 上调用。

以下是来自载入流 Controller 的相关代码,它显示了主应用程序流 Controller 。

// The presenting view controller from the onboarding flow
@implementation TLOnboardingStep2ViewController
  -(void)presentMainViewController {
      UIStoryboard *board = [UIStoryboard storyboardWithName"Main" bundle:nil];

      // The root view controller of the main app flow
      ECSlidingViewController *slidingVC = [board instantiateViewControllerWithIdentifier"slidingViewController"];
      [self presentViewController:slidingVC animated:YES completion:^{
          [[UIApplication sharedApplication].delegate window].rootViewController = slidingVC;
          [self.navigationController removeFromParentViewController];
      }];
  }
@end

我在这里做错了什么?谢谢。



Best Answer-推荐答案


似乎更好的处理方法是让主应用程序流作为 Root View Controller ,并在需要时作为模态视图 Controller 从主视图 Controller 弹出到登录流中。这就是我现在正在做的事情,它似乎工作得更好,并且使层次结构更加清晰。

关于ios - 初次入职后如何过渡到主应用程序流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20941139/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4