在需要注册的应用程序中管理视图控制器 [英] Managing view controllers in an app where sign up required

查看:73
本文介绍了在需要注册的应用程序中管理视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的iOS应用遵循一种类似于Instagram所示的导航模式:

I want my iOS app to follow a navigation pattern similar to the one shown in Instagram:

也就是说,如果用户尚未登录,则会显示欢迎视图.从那里,用户可以导航到登录视图或注册视图.成功完成登录后,该视图将向下滑动消失,然后在下面显示主应用程序视图.如果用户注销,将再次显示欢迎视图.

That is... if user hasn't signed in, a welcome view is displayed. From there, user can navigate to either the sign in view or the register view. When sign in is successfully completed, the view is dismissed sliding down, and then the main app view is shown below. If user logs out, the welcome view is shown again.

我的应用程序也是选项卡式的.我已将AppDelegate中的rootViewController设置为UITabBarController,并尝试通过显示来显示 welcome>登录/ welcome>注册导航层次结构从UITabBarController的主视图来看它是UINavigationController(正如我所说的,它是rootViewController).但是问题在于,为了从主视图中呈现欢迎视图,即使用户尚未登录,我也需要首先显示主视图.而且我不希望用户如果未登录就可以看到主视图.

My app is also a tabbed one. I've set the rootViewController in AppDelegate to be the UITabBarController, and I tried showing the welcome > sign in / welcome > register navigation hierarchy by presenting its UINavigationController from the main view in the UITabBarController (that, as I said, is the rootViewController). But the problem is that, for presenting the welcome view from the main view, I need to show the main view first, even if the user has not logged in yet. And I don't want the user to see the main view if not logged in.

我还尝试检查用户是否已在应用程序启动时登录,并且如果需要登录,请用欢迎视图填充UITabBarController(即rootViewController)并隐藏选项卡栏.然后从那里显示登录视图,如果登录成功,则将其关闭,并在此时将UITabBarController与主视图以及我的应用程序的其他选项卡项一起填充.但是这里的问题是,当我关闭签入视图时,欢迎视图在主视图和其余选项卡项目加载之前显示如下.而且我也不想让用户在关闭登录视图后再次看到欢迎视图,我不想像Instagram一样直接显示主视图.

I also tried checking if user is already logged in at the start of the app, and if log in required, populating the UITabBarController that is the rootViewController with the welcome view and hiding the tab bar. Then presenting the sign in view from there, and dismissing it if log in is succesful and populating at this point the UITabBarController with the main view and the rest of the tab items of my app. But here the problem is that, when I dismiss the sign in view, the welcome view is shown below before the main view and the rest of tab items are loaded. And I neither want the user to see again the welcome view when the sign in view is dismissed, I want to show the main view directly, as Instagram does.

如何实现类似Instagram的行为?

How could I achieve a behaviour like in Instagram?

预先感谢

推荐答案

在应用程序启动时,确定用户是否已经登录.

At the start of the app, determine whether or not the user is logged in already.

如果用户未登录:

  • 将rootViewController设置为UINavigationController并添加您的 欢迎查看. (如果希望导航栏看起来像您发布的照片​​,则可以将其隐藏.)
  • 当他们点击注册或登录按钮时, 将适当的视图控制器推到导航控制器上 堆栈.
  • 成功登录后,用UITabBarController 替换根视图控制器.
  • Set the rootViewController to a UINavigationController and add your Welcome view to it. (You can hide the navigation bar if you want it to look like the photo that you posted.)
  • When they tap the register or sign in buttons, push the appropriate view controller onto the navigation controller stack.
  • After a successful login, replace the root view controller with the UITabBarController.

如果用户已登录:

将rootViewController设置为UITabBarController.

Set the rootViewController to the UITabBarController.

这篇关于在需要注册的应用程序中管理视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆