呈现 UINavigationController 多个深度视图,作为初始视图
在我的应用程序中,我希望有一个初始屏幕,允许用户注册(基于网络的)服务。完成此操作后,他们将自动登录。这些屏幕将显示为 UINavigationController 中的视图,类似于:
1.Opening view > 2.Sign up view > 3.Logging in view > 4.Logged in view
注册后,下次启动应用程序时,应用程序应直接转到视图 3(记录在)。我将如何将这一观点呈现为最初的观点? (另一个问题 - 如果用户决定注销,我如何从视图 4 返回到视图 1?)
In my app I would like to have an initial screen which allows the user to sign up for a (web-based) service. Once they have done this, they will automatically log in. These screens will be presented as views within a UINavigationController, something like:
1.Opening view > 2.Sign up view > 3.Logging in view > 4.Logged in view
Once they have signed up, the next time the app is launched, the app should go straight to view 3 (logging in). How would I present this view as the initial one?
(an additional question - how would I return to view 1 from view 4 if the user decides to log out?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
字面上的答案(“如何更改初始视图?”)将是更改您的应用程序委托:
在您的 xib 文件中使用两个 UINavigationController。但这可能感觉有点不正统,并会引发其他问题。否则,通过让视图控制器 1 和 2 立即推送下一个控制器而不使用动画,立即推送整个视图控制器堆栈。
然后用户将只看到“登录视图”。如果您决定让用户从堆栈中弹出视图 4 和 3,则视图控制器 2 将出现。
您可以通过调用类似
[self.navigationController popToRootViewControllerAnimated:NO]
来弹出整个堆栈The literal answer (to "how to change initial view?") would be to alter you app delegate:
with two UINavigationControllers in your xib file. But this may feel a little unorthodox and give rise to other issues. Otherwise, instantly push the whole viewcontroller stack on it, by having your viewcontrollers 1 and 2 immediately push the next controllers without animation.
The user will then just see the "Logging in view". If you decide to let the user pop views 4 and 3 off the stack, viewcontroller 2 will appear.
You can pop the entire stack by calling something like
[self.navigationController popToRootViewControllerAnimated:NO]