我有一个关于在应用程序启动时加载 View Controller 的问题。我想要一个条件来检查应用程序何时根据存储的核心数据值启动,如果为真,它将加载堆栈中第二个 View Controller 。如果为假,我想加载 Root View Controller 。无论条件结果如何,我都想始终保留 Root View Controller ,如果我的条件结果为真,我只想跳过加载此 View 并直接转到堆栈中的第二个 View 。我没有使用 Storyboard。以前有人做过这种性质的事情吗?
现在,话虽如此,这个逻辑流程是否是一个可以接受的实现解决方案。如果我这样尝试,提交过程中会不会有问题?
最佳答案
假设您有以下 View Controller :
UINavigationController *navigationController;
UIViewController *firstViewController;
UIViewController *secondViewController;
然后你可以这样写代码(编辑:根据下面的评论修改解决方案):
if (yourCondition)
navigationController.viewControllers = @[ firstViewController, secondViewController ];
else
navigationController.viewControllers = @[ secondViewController, firstViewController ];
关于ios - Objective-c 在应用程序启动后有条件地提供 ViewControllers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21785311/