Question

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

instagram_iPhone_1 instagram_iPhone_2 instagram_iPhone_3

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.

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.

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.

How could I achieve a behaviour like in Instagram?

Thanks in advance

Was it helpful?

Solution

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

If the user is not logged in:

  • 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.

If the user is logged in:

Set the rootViewController to the UITabBarController.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top